aboutsummaryrefslogtreecommitdiff
path: root/go.py
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2023-06-02 13:02:08 +0200
committerInigoGutierrez <inigogf.95@gmail.com>2023-06-02 13:02:08 +0200
commit88fbf5f8919211cfa06116a76f42fb26ec9f2e18 (patch)
tree962d26ca9b07bb28fae607e4d8ba4008893b1900 /go.py
parent2d895e4abb26eccefe6b4bc201fd60eb79600e3e (diff)
downloadimago-88fbf5f8919211cfa06116a76f42fb26ec9f2e18.tar.gz
imago-88fbf5f8919211cfa06116a76f42fb26ec9f2e18.zip
Second revision and added rules of the game.
Diffstat (limited to 'go.py')
-rwxr-xr-xgo.py30
1 files changed, 25 insertions, 5 deletions
diff --git a/go.py b/go.py
index cf0a673..c6553df 100755
--- a/go.py
+++ b/go.py
@@ -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)