Skip to content

Commit

Permalink
Merge 8433c34 into 07c1ee2
Browse files Browse the repository at this point in the history
  • Loading branch information
bcollazo committed Dec 9, 2023
2 parents 07c1ee2 + 8433c34 commit d22e642
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ jobs:
- name: Inline test
run: |
python -c "import gymnasium as gym; env = gym.make('catanatron_gym:catanatron-v0')"
- name: Test README.md sample (and fail even on warnings)
run: |
ls
python -W error catanatron_gym/sample.py
build-ui:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion all-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ colorama==0.4.6
coverage==6.5.0
coveralls==3.3.1
docopt==0.6.2
Farama-Notifications==0.0.4
Flask==2.2.3
Flask-Cors==3.0.10
Flask-SQLAlchemy==3.0.3
gunicorn==20.1.0
gymnasium==0.27.1
gymnasium==0.29.1
gymnasium-notices==0.0.1
idna==3.4
iniconfig==2.0.0
Expand Down
14 changes: 14 additions & 0 deletions catanatron_gym/sample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import random
import gymnasium as gym

env = gym.make("catanatron_gym:catanatron-v0")
observation, info = env.reset()
for _ in range(1000):
action = random.choice(
env.get_valid_actions()
) # your agent here (this takes random actions)

observation, reward, done, info = env.step(action)
if done:
observation, info = env.reset()
env.close()
4 changes: 2 additions & 2 deletions catanatron_gym/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name="catanatron_gym",
version="3.2.1",
version="4.0.0",
author="Bryan Collazo",
author_email="bcollazo2010@gmail.com",
description="Open AI Gym to play 1v1 Catan against a random bot",
Expand All @@ -22,5 +22,5 @@
"Operating System :: OS Independent",
],
python_requires=">=3.6",
install_requires=["catanatron", "gymnasium", "numpy"],
install_requires=["catanatron", "gymnasium==0.29.1", "numpy"],
)
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
-e catanatron_experimental
click==8.1.3
cloudpickle==2.2.1
Farama-Notifications==0.0.4
Flask==2.2.3
Flask-Cors==3.0.10
Flask-SQLAlchemy==3.0.3
gunicorn==20.1.0
gymnasium==0.27.1
gymnasium==0.29.1
gymnasium-notices==0.0.1
itsdangerous==2.1.2
jax-jumpy==1.0.0
Expand Down
28 changes: 12 additions & 16 deletions sample.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
from catanatron import Game, RandomPlayer, Color
import random
import gymnasium as gym

from catanatron_experimental.my_player import MyPlayer
from catanatron_server.utils import open_link
env = gym.make("catanatron_gym:catanatron-v0")
observation, info = env.reset()
for _ in range(1000):
action = random.choice(
env.get_valid_actions()
) # your agent here (this takes random actions)

# Play a simple 4v4 game. Edit MyPlayer with your logic!
players = [
MyPlayer(Color.RED),
RandomPlayer(Color.BLUE),
RandomPlayer(Color.WHITE),
RandomPlayer(Color.ORANGE),
]
game = Game(players)
print(game.play()) # returns winning color

# Ensure you have `docker-compose up` running
# in another terminal tab:
open_link(game) # opens game result in browser
observation, reward, done, info = env.step(action)
if done:
observation, info = env.reset()
env.close()

0 comments on commit d22e642

Please sign in to comment.