diff options
Diffstat (limited to 'go.py')
-rwxr-xr-x | go.py | 30 |
1 files changed, 25 insertions, 5 deletions
@@ -2,14 +2,17 @@ """Play Go!""" +import sys + from imago.engine.parseHelpers import parseVertex from imago.gameLogic.gameState import GameState -if __name__ == "__main__": +def runGame(): GAMESTATE = GameState(9) + gameEnded = False - while True: + while not gameEnded: GAMESTATE.getBoard().printBoard() @@ -23,7 +26,24 @@ if __name__ == "__main__": print() - moveRow = move[0] - moveCol = move[1] + if move == "pass": + + GAMESTATE.playPass() + if GAMESTATE.lastMove.previousMove.isPass: + print("Both players passed: end of the game.") + gameEnded = True + + else: - GAMESTATE.playMove(moveRow, moveCol) + moveRow = move[0] + moveCol = move[1] + GAMESTATE.playMove(moveRow, moveCol) + +if __name__ == "__main__": + + try: + runGame() + except KeyboardInterrupt as err: + print() + print("Quitting: End of the game.") + sys.exit(0) |