1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
ReAct Agent for Pokemon TCG.
This module provides a ReAct-style AI agent for playing Pokemon TCG
against the deterministic AI (v4) opponent.
Architecture Overview:
---------------------
1. HeadlessGame: Manages game state and provides text-based observations
2. ReactAgent: LLM-based agent that selects actions from observations
3. GameRunner: Orchestrates gameplay between ReactAgent and AI opponent
Example Usage:
--------------
```python
import asyncio
from tcg_ai.react import HeadlessGame, ReactAgent, GameRunner
async def main():
# Create a headless game
game = HeadlessGame(seed=42, p1_deck=deck1, p2_deck=deck2)
# Create a react agent with OpenAI
agent = ReactAgent(
api_key="your-api-key",
model="gpt-4",
)
# Run a game
runner = GameRunner(game, agent)
result = await runner.run()
print(f"Winner: {result['winner']}")
print(f"Turns: {result['turns']}")
asyncio.run(main())
```
"""
=