#!/usr/bin/python """Play Go!""" import sys from imago.engine.parseHelpers import parseVertex from imago.gameLogic.gameState import GameState def runGame(): GAMESTATE = GameState(9) gameEnded = False while not gameEnded: GAMESTATE.getBoard().printBoard() move = input("Move (" + GAMESTATE.getPlayerCode() + "): ") try: move = parseVertex(move, GAMESTATE.size) except Exception as err: print("Invalid move syntax. Example of move: A1") print() continue if move == "pass": GAMESTATE.playPass() if GAMESTATE.lastMove.previousMove.isPass: print("Both players passed: end of the game.") gameEnded = True else: moveRow = move[0] moveCol = move[1] try: GAMESTATE.playMove(moveRow, moveCol) except Exception as err: print(err) print() if __name__ == "__main__": try: runGame() except KeyboardInterrupt as err: print() print("Quitting: End of the game.") print() sys.exit(0)