aboutsummaryrefslogtreecommitdiff
path: root/go.py
diff options
context:
space:
mode:
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)