Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug: When game is over, all moves should be invalid #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gym_go/gogame.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def batch_next_states(batch_states, batch_action1d, canonical=False):
def invalid_moves(state):
# return a fixed size binary vector
if game_ended(state):
return np.zeros(action_size(state))
return np.ones(action_size(state))
return np.append(state[govars.INVD_CHNL].flatten(), 0)


Expand Down
4 changes: 3 additions & 1 deletion gym_go/tests/test_invalid_moves.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import gym
import numpy as np

from gym_go import govars
from gym_go import govars, gogame


class TestGoEnvInvalidMoves(unittest.TestCase):
Expand Down Expand Up @@ -175,6 +175,8 @@ def test_invalid_game_already_over_move(self):
with self.assertRaises(Exception):
self.env.step((0, 0))

self.assertTrue((gogame.invalid_moves(self.env.state()) == 1).all())

def test_small_suicide(self):
"""
7, 8, 0,
Expand Down