def build_game_master(
    model: language_model.LanguageModel,
    embedder: Callable[[str], np.ndarray],
    importance_model: importance_function.ImportanceModel,
    clock: game_clock.MultiIntervalClock,
    players: Sequence[entity_agent_with_logging.EntityAgentWithLogging],
    shared_memories: Sequence[str],
    shared_context: str,
    blank_memory_factory: blank_memories.MemoryFactory,
    cap_nonplayer_characters_in_conversation: int = 0,
    memory: associative_memory.AssociativeMemory | None = None,
    supporting_players_at_fixed_locations: Sequence[str] | None = None,
    additional_components: Sequence[component.Component] | None = tuple([]),
    thought_chain: (
        Sequence[
            Callable[[interactive_document.InteractiveDocument, str, str], str]
        ]
        | None
    ) = None,
    npc_context: str = '',
    max_conversation_length: int = 10,
    verbose: bool = False,
    seed: int | None = None,
) -> tuple[game_master.GameMaster, associative_memory.AssociativeMemory]:
  """Build a game master (i.e., an environment).

  Args:
    model: The language model to use for game master.
    embedder: The embedder to use for similarity retrieval of memories.
    importance_model: The importance model to use for game master memories.
    clock: The simulation clock.
    players: The players.
    shared_memories: Sequence of memories to be observed by all players.
    shared_context: A shared context string to be observed by all players, even
      temporary non-player characters.
    blank_memory_factory: The factory to use for blank memories of temporary
      non-player characters.
    cap_nonplayer_characters_in_conversation: The maximum number of simple
      non-player characters (without memory) to include in conversations.
    memory: optionally provide a prebuilt memory, otherwise build it here.
    supporting_players_at_fixed_locations: The locations where supporting
      characters who never move are located.
    additional_components: Add more components specific to the current
      environment.
    thought_chain: The thought chain to use for the game master.
    npc_context: extra context provided only to non-player characters
    max_conversation_length: The maximum number of turns in a conversation.
    verbose: whether or not to print verbose debug information
    seed: random seed for the chain of thought document

  Returns:
    A tuple consisting of a game master and its memory.
  """
  if memory is not None:
    game_master_memory = memory
  else:
    game_master_memory = associative_memory.AssociativeMemory(
        sentence_embedder=embedder,
        importance=importance_model.importance,
        clock=clock.now,
    )

  player_names = [player.name for player in players]

  scenario_knowledge = generic_components.constant.ConstantComponent(
      state='\n'.join(shared_memories), name='Background:\n'
  )

  if supporting_players_at_fixed_locations is not None:
    supporting_character_locations_if_any = (
        generic_components.constant.ConstantComponent(
            state='\n'.join(supporting_players_at_fixed_locations),
            name='Notes:\n',
        )
    )
  else:
    supporting_character_locations_if_any = (
        generic_components.constant.ConstantComponent(state='', name='Notes:\n')
    )

  player_status = gm_components.player_status.PlayerStatus(
      clock_now=clock.now,
      model=model,
      memory=game_master_memory,
      player_names=player_names,
  )

  convo_externality = gm_components.conversation.Conversation(
      players=players,
      model=model,
      memory=game_master_memory,
      clock=clock,
      burner_memory_factory=blank_memory_factory,
      components=[player_status],
      cap_nonplayer_characters=cap_nonplayer_characters_in_conversation,
      shared_context=f'{shared_context}\n{npc_context}',
      max_conversation_length=max_conversation_length,
  )

  direct_effect_externality = gm_components.direct_effect.DirectEffect(
      players=players,
      model=model,
      memory=game_master_memory,
      clock_now=clock.now,
      components=[player_status, supporting_character_locations_if_any],
  )

  relevant_events = gm_components.relevant_events.RelevantEvents(
      clock.now, model, game_master_memory
  )
  time_display = gm_components.time_display.TimeDisplay(clock)

  # Create the game master's thought chain
  account_for_agency_of_others = thought_chains_lib.AccountForAgencyOfOthers(
      model=model, players=players, verbose=False
  )
  thought_chain = thought_chain or [
      thought_chains_lib.extract_direct_quote,
      thought_chains_lib.attempt_to_most_likely_outcome,
      thought_chains_lib.result_to_effect_caused_by_active_player,
      account_for_agency_of_others,
      thought_chains_lib.restore_direct_quote,
  ]

  # Create the game master object
  env = game_master.GameMaster(
      model=model,
      memory=game_master_memory,
      clock=clock,
      players=players,
      update_thought_chain=thought_chain,
      components=[
          scenario_knowledge,
          relevant_events,
          supporting_character_locations_if_any,
          player_status,
          convo_externality,
          direct_effect_externality,
          time_display,
          *additional_components,
      ],
      randomise_initiative=True,
      player_observes_event=False,
      seed=seed,
      verbose=verbose,
  )

  return env, game_master_memory
Build a game master (i.e., an environment).

  Args:
    model: The language model to use for game master.
    embedder: The embedder to use for similarity retrieval of memories.
    importance_model: The importance model to use for game master memories.
    clock: The simulation clock.
    players: The players.
    shared_memories: Sequence of memories to be observed by all players.
    shared_context: A shared context string to be observed by all players, even
      temporary non-player characters.
    blank_memory_factory: The factory to use for blank memories of temporary
      non-player characters.
    cap_nonplayer_characters_in_conversation: The maximum number of simple
      non-player characters (without memory) to include in conversations.
    memory: optionally provide a prebuilt memory, otherwise build it here.
    supporting_players_at_fixed_locations: The locations where supporting
      characters who never move are located.
    additional_components: Add more components specific to the current
      environment.
    thought_chain: The thought chain to use for the game master.
    npc_context: extra context provided only to non-player characters
    max_conversation_length: The maximum number of turns in a conversation.
    verbose: whether or not to print verbose debug information
    seed: random seed for the chain of thought document

  Returns:
    A tuple consisting of a game master and its memory.
  
concordia/deprecated/factory/environment/basic_game_master.py