-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpychess.py
More file actions
30 lines (24 loc) · 719 Bytes
/
pychess.py
File metadata and controls
30 lines (24 loc) · 719 Bytes
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
from game.game import Game, IllegalMoveException
from pieces.moves import Move
class PyChess(object):
@staticmethod
def new_game():
return Game()
@staticmethod
def start():
game = PyChess.new_game()
game.start()
print("====== Starting new game")
while True:
try:
print(game.board)
game.handle_mate()
game.handle_check()
move = input(f"====== {game.current_player}'s move\n")
game.move(move)
except IllegalMoveException as e:
print(e)
else:
game.switch_players()
if __name__ == '__main__':
PyChess.start()