-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHuman_Player.py
More file actions
29 lines (24 loc) · 1.12 KB
/
Human_Player.py
File metadata and controls
29 lines (24 loc) · 1.12 KB
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
from Player import Player
class Human_Player(Player):
def __init__(self, name, marker):
self.name = name
self.marker = marker
def get_move(self, game_state):
while True:
move_address = input("\nEnter your move (column first, e.g. A1 or C3): ").capitalize()
if len(move_address) != 2:
print("Invalid move. Your move should be just two characters long.")
continue
if move_address[0] not in game_state.column_names:
print("Invalid move. The first character needs to be one of: ", game_state.column_names)
continue
if move_address[1] not in game_state.row_names:
print("Invalid move. The second character needs to be one of: ", game_state.row_names)
continue
if not game_state.puzzle_dict[move_address].is_open():
print("Invalid move. That location is already taken.")
continue
return game_state.puzzle_dict[move_address]
@staticmethod
def get_user_name():
return input('Please enter your name: ')