-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
36 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |