def determine_success_and_why(
    chain_of_thought: interactive_document.InteractiveDocument,
    action_attempt: str,
    active_player_name: str,
):
  """Determine success of action_attempt and reason for success/failure.

  Args:
    chain_of_thought: the document to condition on and record the thoughts
    action_attempt: the attempted action
    active_player_name: name of player whose turn it currently is

  Returns:
    string describing the outcome
  """
  del active_player_name
  success = chain_of_thought.yes_no_question(
      'Does the attempted action succeed? If the attempted action '
      + 'is easy to accomplish then the attempt should be successful '
      + 'unless there is a specific reason for it to fail.'
  )
  why_failed = 'this failed'  # will be overwritten if needed.
  if success:
    chain_of_thought.statement('The attempt succeeded.')
  else:
    chain_of_thought.statement('The attempt failed.')
    why_failed = chain_of_thought.open_question(
        'Why did the attempt fail?',
    )

  if action_attempt[-1] == '.':
    action_attempt = action_attempt[:-1] + ','
  success_or_not = 'successful' if success else 'not successful'
  result = f'{action_attempt} and was {success_or_not}.'
  if not success:
    result = f'{result}. However, {why_failed}'

  chain_of_thought.statement(result)
  return result
Determine success of action_attempt and reason for success/failure.

  Args:
    chain_of_thought: the document to condition on and record the thoughts
    action_attempt: the attempted action
    active_player_name: name of player whose turn it currently is

  Returns:
    string describing the outcome
  
concordia/thought_chains/deprecated/thought_chains.py