MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / GameContext

Class GameContext

codeclash/agents/utils.py:10–38  ·  view source on GitHub ↗

A class that gives agent access to a partial view of the game state. NOTE: Instead of passing `game` directly as a reference to the agent, we create this interface instead to make the communication of game state more explicit and controlled. We go with this loose coupling to avoid

Source from the content-addressed store, hash-verified

8
9
10class GameContext(BaseModel):
11 """
12 A class that gives agent access to a partial view of the game state.
13
14 NOTE: Instead of passing `game` directly as a reference to the agent,
15 we create this interface instead to make the communication of game state
16 more explicit and controlled. We go with this loose coupling to avoid
17 making the agent too dependent on the entire game object.
18 """
19
20 id: str
21 log_env: Path
22 log_local: Path
23 name: str
24 player_id: str
25 prompts: dict
26 round: int
27 rounds: int
28 working_dir: str
29 arena_description: str = ""
30
31 def _render_prompt_templates(self) -> dict:
32 context = self.model_dump()
33 return {key: Template(template_str).render(**context) for key, template_str in self.prompts.items()}
34
35 def to_template_vars(self) -> dict[str, str]:
36 """Convert the GameContext to a dictionary for rendering prompts in the agent"""
37 out = self.model_dump() | self._render_prompt_templates()
38 out.pop("prompts")
39 return out

Callers 3

_create_dummy_agentMethod · 0.90
get_agentMethod · 0.90
get_game_contextMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected