From c5f4f9526af8f8aa057ead5ed623b04e189ca44e Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Sun, 1 May 2022 10:48:41 +1000 Subject: [PATCH 1/6] Explicitly specify gym version 0.20.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d33850a..5c0f3d4 100644 --- a/setup.py +++ b/setup.py @@ -3,5 +3,5 @@ setup( name='gym_go', version='0.0.1', - install_requires=['gym'] # and other dependencies + install_requires=['gym==0.20.0'] # and other dependencies ) From 53ffc843eb08ff25224bf27f824ab293266e25b6 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Sun, 1 May 2022 12:02:56 +1000 Subject: [PATCH 2/6] Bump gym version to 0.21.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5c0f3d4..85f9319 100644 --- a/setup.py +++ b/setup.py @@ -3,5 +3,5 @@ setup( name='gym_go', version='0.0.1', - install_requires=['gym==0.20.0'] # and other dependencies + install_requires=['gym==0.21.0'] # and other dependencies ) From 6eca9a8ca2a0cc9271b0a6206e7c20b7b79cfd6a Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Sun, 1 May 2022 12:04:09 +1000 Subject: [PATCH 3/6] Always reset environment before use --- README.md | 1 + demo.py | 1 + gym_go/tests/test_basics.py | 3 +++ gym_go/tests/test_invalid_moves.py | 2 ++ 4 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 943e08d..4059f3a 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ pip install -e . import gym go_env = gym.make('gym_go:go-v0', size=7, komi=0, reward_method='real') +go_env.reset() first_action = (2,5) second_action = (5,2) diff --git a/demo.py b/demo.py index 9c9d2d5..39615f3 100644 --- a/demo.py +++ b/demo.py @@ -10,6 +10,7 @@ # Initialize environment go_env = gym.make('gym_go:go-v0', size=args.boardsize, komi=args.komi) +go_env.reset() # Game loop done = False diff --git a/gym_go/tests/test_basics.py b/gym_go/tests/test_basics.py index 307ed1f..abc4945 100644 --- a/gym_go/tests/test_basics.py +++ b/gym_go/tests/test_basics.py @@ -174,6 +174,7 @@ def test_num_liberties(self): def test_komi(self): env = gym.make('gym_go:go-v0', size=7, komi=2.5, reward_method='real') + env.reset() # White win _ = env.step(None) @@ -224,6 +225,7 @@ def test_children(self): def test_real_reward(self): env = gym.make('gym_go:go-v0', size=7, reward_method='real') + env.reset() # In game state, reward, done, info = env.step((0, 0)) @@ -259,6 +261,7 @@ def test_real_reward(self): def test_heuristic_reward(self): env = gym.make('gym_go:go-v0', size=7, reward_method='heuristic') + env.reset() # In game state, reward, done, info = env.step((0, 0)) diff --git a/gym_go/tests/test_invalid_moves.py b/gym_go/tests/test_invalid_moves.py index 3693bbe..809d94f 100644 --- a/gym_go/tests/test_invalid_moves.py +++ b/gym_go/tests/test_invalid_moves.py @@ -186,6 +186,7 @@ def test_small_suicide(self): """ self.env = gym.make('gym_go:go-v0', size=3, reward_method='real') + self.env.reset() for move in [6, 7, 8, 5, 4, 8, 0, 1]: state, reward, done, info = self.env.step(move) @@ -203,6 +204,7 @@ def test_invalid_after_capture(self): """ self.env = gym.make('gym_go:go-v0', size=3, reward_method='real') + self.env.reset() for move in [0, 8, 6, 4, 1, 2, 3, 7]: state, reward, done, info = self.env.step(move) From b4fa9964cb9931af028401f1ed3f5643e833e6c2 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Sun, 1 May 2022 12:12:01 +1000 Subject: [PATCH 4/6] Bump gym version to 0.22.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 85f9319..7771a43 100644 --- a/setup.py +++ b/setup.py @@ -3,5 +3,5 @@ setup( name='gym_go', version='0.0.1', - install_requires=['gym==0.21.0'] # and other dependencies + install_requires=['gym==0.22.0'] # and other dependencies ) From 1636be69f6613d88adfc075720548cafbf6a8308 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Sun, 1 May 2022 12:13:33 +1000 Subject: [PATCH 5/6] Explicitly require gym_go gym.make no longer does this for us --- README.md | 3 ++- demo.py | 3 ++- gym_go/tests/efficiency.py | 3 ++- gym_go/tests/test_basics.py | 14 +++++++------- gym_go/tests/test_invalid_moves.py | 6 +++--- gym_go/tests/test_valid_moves.py | 2 +- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 4059f3a..d0bd5e7 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,9 @@ pip install -e . ### Coding example ```python import gym +import gym_go -go_env = gym.make('gym_go:go-v0', size=7, komi=0, reward_method='real') +go_env = gym.make('go-v0', size=7, komi=0, reward_method='real') go_env.reset() first_action = (2,5) diff --git a/demo.py b/demo.py index 39615f3..7d6a05f 100644 --- a/demo.py +++ b/demo.py @@ -1,6 +1,7 @@ import argparse import gym +import gym_go # Arguments parser = argparse.ArgumentParser(description='Demo Go Environment') @@ -9,7 +10,7 @@ args = parser.parse_args() # Initialize environment -go_env = gym.make('gym_go:go-v0', size=args.boardsize, komi=args.komi) +go_env = gym.make('go-v0', size=args.boardsize, komi=args.komi) go_env.reset() # Game loop diff --git a/gym_go/tests/efficiency.py b/gym_go/tests/efficiency.py index 7b179b7..392ca11 100644 --- a/gym_go/tests/efficiency.py +++ b/gym_go/tests/efficiency.py @@ -2,6 +2,7 @@ import unittest import gym +import gym_go import numpy as np from tqdm import tqdm @@ -11,7 +12,7 @@ class Efficiency(unittest.TestCase): iterations = 64 def setUp(self) -> None: - self.env = gym.make('gym_go:go-v0', size=self.boardsize, reward_method='real') + self.env = gym.make('go-v0', size=self.boardsize, reward_method='real') def testOrderedTrajs(self): durs = [] diff --git a/gym_go/tests/test_basics.py b/gym_go/tests/test_basics.py index abc4945..e015460 100644 --- a/gym_go/tests/test_basics.py +++ b/gym_go/tests/test_basics.py @@ -10,13 +10,13 @@ class TestGoEnvBasics(unittest.TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.env = gym.make('gym_go:go-v0', size=7, reward_method='real') + self.env = gym.make('go-v0', size=7, reward_method='real') def setUp(self): self.env.reset() def test_state(self): - env = gym.make('gym_go:go-v0', size=7) + env = gym.make('go-v0', size=7) state = env.reset() self.assertIsInstance(state, np.ndarray) self.assertEqual(state.shape[0], govars.NUM_CHNLS) @@ -27,7 +27,7 @@ def test_board_sizes(self): expected_sizes = [7, 13, 19] for expec_size in expected_sizes: - env = gym.make('gym_go:go-v0', size=expec_size) + env = gym.make('go-v0', size=expec_size) state = env.reset() self.assertEqual(state.shape[1], expec_size) self.assertEqual(state.shape[2], expec_size) @@ -150,7 +150,7 @@ def test_game_does_not_end_with_disjoint_passes(self): self.assertFalse(done) def test_num_liberties(self): - env = gym.make('gym_go:go-v0', size=7) + env = gym.make('go-v0', size=7) steps = [(0, 0), (0, 1)] libs = [(2, 0), (1, 2)] @@ -173,7 +173,7 @@ def test_num_liberties(self): self.assertEqual(whitelibs, libs[1], state) def test_komi(self): - env = gym.make('gym_go:go-v0', size=7, komi=2.5, reward_method='real') + env = gym.make('go-v0', size=7, komi=2.5, reward_method='real') env.reset() # White win @@ -224,7 +224,7 @@ def test_children(self): self.assertTrue((children[a] == 0).all()) def test_real_reward(self): - env = gym.make('gym_go:go-v0', size=7, reward_method='real') + env = gym.make('go-v0', size=7, reward_method='real') env.reset() # In game @@ -260,7 +260,7 @@ def test_real_reward(self): env.close() def test_heuristic_reward(self): - env = gym.make('gym_go:go-v0', size=7, reward_method='heuristic') + env = gym.make('go-v0', size=7, reward_method='heuristic') env.reset() # In game diff --git a/gym_go/tests/test_invalid_moves.py b/gym_go/tests/test_invalid_moves.py index 809d94f..2bb85ca 100644 --- a/gym_go/tests/test_invalid_moves.py +++ b/gym_go/tests/test_invalid_moves.py @@ -11,7 +11,7 @@ class TestGoEnvInvalidMoves(unittest.TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.env = gym.make('gym_go:go-v0', size=7, reward_method='real') + self.env = gym.make('go-v0', size=7, reward_method='real') def setUp(self): self.env.reset() @@ -185,7 +185,7 @@ def test_small_suicide(self): :return: """ - self.env = gym.make('gym_go:go-v0', size=3, reward_method='real') + self.env = gym.make('go-v0', size=3, reward_method='real') self.env.reset() for move in [6, 7, 8, 5, 4, 8, 0, 1]: state, reward, done, info = self.env.step(move) @@ -203,7 +203,7 @@ def test_invalid_after_capture(self): :return: """ - self.env = gym.make('gym_go:go-v0', size=3, reward_method='real') + self.env = gym.make('go-v0', size=3, reward_method='real') self.env.reset() for move in [0, 8, 6, 4, 1, 2, 3, 7]: state, reward, done, info = self.env.step(move) diff --git a/gym_go/tests/test_valid_moves.py b/gym_go/tests/test_valid_moves.py index 0e54064..a3806b5 100644 --- a/gym_go/tests/test_valid_moves.py +++ b/gym_go/tests/test_valid_moves.py @@ -10,7 +10,7 @@ class TestGoEnvValidMoves(unittest.TestCase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.env = gym.make('gym_go:go-v0', size=7, reward_method='real') + self.env = gym.make('go-v0', size=7, reward_method='real') def setUp(self): self.env.reset() From 83648efe9a6524c7fb2a13e4b6bad9f18720f88c Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Sun, 1 May 2022 12:21:44 +1000 Subject: [PATCH 6/6] Bump gym version to 0.23.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7771a43..c86abb7 100644 --- a/setup.py +++ b/setup.py @@ -3,5 +3,5 @@ setup( name='gym_go', version='0.0.1', - install_requires=['gym==0.22.0'] # and other dependencies + install_requires=['gym==0.23.1'] # and other dependencies )