forked from Alessio-Parmeggiani/HRI_Pepper_Tris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgm_tris.py
48 lines (36 loc) · 1.33 KB
/
gm_tris.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
41
42
43
44
45
46
47
48
# This is ONLY for test games via command line
from tris import *
from planner_tris import *
from agent_tris import *
class GameManager:
def __init__(self, pepper_player):
self.game = Tris()
self.pepper_player = pepper_player
self.agent = Agent(self.game, pepper_player)
def on_human_move(self, move):
pass # TODO
def play_match(self):
self.game.reset()
self.agent = Agent(self.game, self.pepper_player)
while not self.game.get_game_over_and_winner()[0]:
#agent turn
opponent_move=self.agent.on_my_turn()
self.game.move(*opponent_move)
print self.game
if self.game.get_game_over_and_winner()[0]:
break
#player turn
player_row = int(input("your row: "))
player_col = int(input("your column: "))
player_move = (player_row, player_col)
print("your move is: ",player_move)
self.game.move(*player_move)
self.agent.on_opponent_move(player_move)
print self.game
print "^_^"
print ""
print "WINNER IS: " + str(self.game.get_game_over_and_winner()[1])
print ""
if __name__ == "__main__":
game_manager = GameManager(Tris.X)
game_manager.play_match()