Skip to content

Commit 5aeaf61

Browse files
authored
games.py Gomoku (#1080)
* update games.py connect 4 display method original code displays board sideways. Fixed display method to print board bottom down * update games.py add Gomoku game Trivially addition of Gomoku, thanks to flexible implementation of TicTacToe class
1 parent 62a5a30 commit 5aeaf61

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

games.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,13 @@ def __init__(self, h=7, v=6, k=4):
424424

425425
def actions(self, state):
426426
return [(x, y) for (x, y) in state.moves
427-
if y == 1 or (x, y - 1) in state.board]
427+
if x == self.h or (x + 1 , y ) in state.board]
428+
429+
class Gomoku(TicTacToe):
430+
"""Also known as Five in a row."""
431+
432+
def __init__(self, h=15, v=16, k=5):
433+
TicTacToe.__init__(self, h, v, k)
428434

429435

430436
class Backgammon(StochasticGame):

0 commit comments

Comments
 (0)