forked from five-in-row-AI/AI_Five-in-row
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.py
31 lines (23 loc) · 959 Bytes
/
player.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
#Player Class
#Gomoku Type Games - Lingliang Zhang / Comp Sci Assignment 4
class Player():
def __init__(self, name,symbol):
self.name = name
self.symbol = symbol
#function that governs a turn
def turn(self, game):
correct = 0
#ask where the player would like to place their piece
while correct == 0:
try:
pos = input('Please type the position you would like to place your piece: ')
if pos in game.remaining:
correct = 1
else:
print "Error: invalid input, please try again!!!. \n"
except:
print "Error: invalid input, please try again, \n"
game.remaining.remove(pos)
self.replace(game, game.position_dict[pos])
def replace(self, game, position):
game.board[position[0]][position[1]] = self.symbol