Merge pull request #2 from tsu-nera/master

Add diagonals in game over conditions
This commit is contained in:
Nicolai Czempin 2017-06-13 15:20:31 +02:00 committed by GitHub
commit e8dcc0fb4f

View File

@ -34,11 +34,16 @@ class TicTacToeEnv(gym.Env):
# check game over # check game over
for i in range(3): for i in range(3):
# horizontals and verticals # horizontals and verticals
if ((board[i * 3] == p and board[i * 3 + 1] == p and board[i * 3 + 2 ] == p) if ((board[i * 3] == p and board[i * 3 + 1] == p and board[i * 3 + 2] == p)
or (board[i + 0] == p and board[i + 3] == p and board[i + 6] == p)): or (board[i + 0] == p and board[i + 3] == p and board[i + 6] == p)):
reward = p reward = p
done = True done = True
break break
# diagonals
if((board[0] == p and board[4] == p and board[8] == p)
or (board[2] == p and board[4] == p and board[6] == p)):
reward = p
done = True
return self.state, reward, done, {} return self.state, reward, done, {}
def _reset(self): def _reset(self):