blob: 7580c2b7db9eaf093d4773f45fb4f34c5ee5217e (
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
50
51
52
53
|
#!/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)
|