Skip to content

Commit

Permalink
chore: Fix readme example
Browse files Browse the repository at this point in the history
  • Loading branch information
strakam committed Oct 29, 2024
1 parent 5000702 commit 1e7bc6e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,24 @@ that has the signature explained in sections down below.

### Usage Example (🤸 Gymnasium)
The example loop for running the game looks like this
```python:examples/gymnasium_example.py
```python
import gymnasium as gym

from generals.agents import RandomAgent, ExpanderAgent

# Initialize agents
agent = RandomAgent()
npc = ExpanderAgent()

# Create environment
env = gym.make("gym-generals-v0", agent=agent, npc=npc, render_mode="human")

observation, info = env.reset()
terminated = truncated = False
while not (terminated or truncated):
action = agent.act(observation)
observation, reward, terminated, truncated, info = env.step(action)
env.render()
```

> [!TIP]
Expand Down

0 comments on commit 1e7bc6e

Please sign in to comment.