blob: c6553df842bd49ca5bad5d61b1cb667fae3ccc7d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#!/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")
continue
print()
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]
GAMESTATE.playMove(moveRow, moveCol)
if __name__ == "__main__":
try:
runGame()
except KeyboardInterrupt as err:
print()
print("Quitting: End of the game.")
sys.exit(0)
|