diff options
author | InigoGutierrez <inigogf.95@gmail.com> | 2023-06-02 13:02:08 +0200 |
---|---|---|
committer | InigoGutierrez <inigogf.95@gmail.com> | 2023-06-02 13:02:08 +0200 |
commit | 88fbf5f8919211cfa06116a76f42fb26ec9f2e18 (patch) | |
tree | 962d26ca9b07bb28fae607e4d8ba4008893b1900 /go.py | |
parent | 2d895e4abb26eccefe6b4bc201fd60eb79600e3e (diff) | |
download | imago-88fbf5f8919211cfa06116a76f42fb26ec9f2e18.tar.gz imago-88fbf5f8919211cfa06116a76f42fb26ec9f2e18.zip |
Second revision and added rules of the game.
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) |