def configure_scenes(
    model: language_model.LanguageModel,
    game_master_memory: associative_memory.AssociativeMemory,
    players: Sequence[entity_agent_with_logging.EntityAgentWithLogging],
    clock: game_clock.MultiIntervalClock,
    main_player_configs: Sequence[formative_memories.AgentConfig],
    supporting_player_configs: Sequence[formative_memories.AgentConfig],
    start_time: datetime.datetime,
    rng: random.Random,
    sampled_settings: WorldConfig,
) -> tuple[
    Sequence[scene_lib.SceneSpec],
    list[game_master.GameMaster] | list[None],
    Callable[[], Mapping[str, float]],
]:
  """Configure the scene storyboard structure.

  Args:
    model: the language model to use.
    game_master_memory: the game master memory to use.
    players: the players to use.
    clock: the clock to use.
    main_player_configs: configs for the main characters
    supporting_player_configs: configs for the supporting characters
    start_time: the start time of the simulation
    rng: the random number generator to use
    sampled_settings: the sampled settings for the world configuration

  Returns:
    scenes: a sequence of scene specifications
  """

  coordination_payoffs = []
  game_masters = []
  scenes = []

  player_configs = list(main_player_configs) + list(supporting_player_configs)
  main_player_names = set([player.name for player in main_player_configs])

  main_players = [
      player for player in players if player.name in main_player_names
  ]
  supporting_players = [
      player for player in players if player.name not in main_player_names
  ]

  if sampled_settings.only_match_with_support:
    pairs = _create_main_vs_support_pairs(main_players, supporting_players)
  else:
    pairs = _create_all_pairs(players)

  for i in range(sampled_settings.num_games * len(pairs)):

    buyer_base_reward = rng.randint(
        sampled_settings.buyer_base_reward_min,
        sampled_settings.buyer_base_reward_max,
    )
    seller_base_reward = rng.randint(
        sampled_settings.seller_base_reward_min,
        sampled_settings.seller_base_reward_max,
    )

    this_game_players = pairs[i % len(pairs)]

    # It is important that this_game_configs has exactly the same order as
    # this_game_players. Otherwise, the turn order between buyer and seller
    # might be flipped and offer will be accepted or rejected before it is
    # proposed.
    this_game_configs = []
    for player in this_game_players:
      this_game_configs.append(
          [cfg for cfg in player_configs if cfg.name == player.name][0]
      )

    scene_opening = rng.choice(list(sampled_settings.scene_visuals))
    scene_specs = {
        'social': scene_lib.SceneTypeSpec(
            name='day',
            premise={
                this_game_players[0].name: [(
                    f'{scene_opening} {this_game_players[0].name} is trying to'
                    f' buy some fruit from {this_game_players[1].name}. They'
                    f' are negotiating a price. {this_game_players[0].name} can'
                    f' sell the fruit for {buyer_base_reward} coins back in her'
                    ' home town.'
                )],
                this_game_players[1].name: [(
                    f'{scene_opening} {this_game_players[1].name} is  trying to'
                    ' sell some fruit. He is negotiating a price with'
                    f' {this_game_players[0].name}. It costs'
                    f' {this_game_players[1].name} {seller_base_reward} coin to'
                    ' buy the fruit from the farm.'
                )],
            },
        ),
    }

    choice_scene_spec, this_coordination_payoff = add_choice_scene_spec(
        model=model,
        game_master_memory=game_master_memory,
        scene_name=f'Deal or no deal game {i}',
        buyer=this_game_players[0],
        seller=this_game_players[1],
        clock=clock,
        scene_type_name=DECISION_SCENE_TYPE,
        buyer_base_reward=buyer_base_reward,
        seller_base_reward=seller_base_reward,
    )

    coordination_payoffs.append(this_coordination_payoff)
    game_masters.append(choice_scene_spec.override_game_master)
    scene_specs[DECISION_SCENE_TYPE] = choice_scene_spec
    scenes = scenes + [
        scene_lib.SceneSpec(
            scene_type=scene_specs['social'],
            start_time=start_time + i * TIME_INCREMENT_BETWEEN_SCENES,
            participant_configs=this_game_configs,
            num_rounds=2,
        ),
        scene_lib.SceneSpec(
            scene_type=scene_specs[DECISION_SCENE_TYPE],
            start_time=start_time
            + i * TIME_INCREMENT_BETWEEN_SCENES
            + datetime.timedelta(minutes=10),
            participant_configs=this_game_configs,
            num_rounds=1,
        ),
    ]

  def return_payoffs_sum():
    result = collections.defaultdict(float)
    for payoff in coordination_payoffs:
      results_dict = payoff.get_scores()
      for name, score in results_dict.items():
        result[name] += score
    return result

  # choice_scene_spec.override_game_master
  return (scenes, game_masters, return_payoffs_sum)
Configure the scene storyboard structure.

  Args:
    model: the language model to use.
    game_master_memory: the game master memory to use.
    players: the players to use.
    clock: the clock to use.
    main_player_configs: configs for the main characters
    supporting_player_configs: configs for the supporting characters
    start_time: the start time of the simulation
    rng: the random number generator to use
    sampled_settings: the sampled settings for the world configuration

  Returns:
    scenes: a sequence of scene specifications
  
examples/deprecated/modular/environment/haggling.py