-
Notifications
You must be signed in to change notification settings - Fork 0
/
human.py
40 lines (31 loc) · 1.04 KB
/
human.py
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
import chess
class human:
def __init__(self):
self.get_side()
def get_side(self):
# self.white = None
# while self.white is None:
# print("Do you wish to play as white ? (y or n)")
# answer = input()
#
# if answer == "y":
# self.white = True
# elif answer == "n":
# self.white = False
# else:
# print("Please enter 'y' or 'n'")
# Temporarily keep human white for sake of ai simplicity
self.white = True
def make_move(self, game):
move = None
while move is None:
print("Please enter your move")
move = input()
try:
move = chess.Move.from_uci(move)
except:
move = None
if not move in game.legal_moves:
print("You need to enter a legal move")
move = None
return move