2018-02-05 22:50:31 +00:00
|
|
|
from cup import Cup
|
|
|
|
import random
|
|
|
|
|
|
|
|
class Bot:
|
|
|
|
|
2018-02-07 14:31:05 +00:00
|
|
|
def __init__(self, board, sym, network):
|
2018-02-05 22:50:31 +00:00
|
|
|
self.cup = Cup()
|
|
|
|
self.board = board
|
|
|
|
self.sym = sym
|
2018-02-07 14:31:05 +00:00
|
|
|
self.network = network
|
2018-02-05 22:50:31 +00:00
|
|
|
|
|
|
|
def roll(self):
|
|
|
|
print("{} rolled: ".format(self.sym))
|
|
|
|
roll = self.cup.roll()
|
|
|
|
print(roll)
|
|
|
|
return roll
|
|
|
|
|
|
|
|
|
|
|
|
def switch(self,cur):
|
2018-02-06 22:29:51 +00:00
|
|
|
return -1 if cur == 1 else 1
|
2018-02-05 22:50:31 +00:00
|
|
|
|
2018-02-06 22:29:51 +00:00
|
|
|
def get_sym(self):
|
|
|
|
return self.sym
|
|
|
|
|
2018-02-05 22:50:31 +00:00
|
|
|
def do_move(self, roll):
|
2018-02-07 15:27:03 +00:00
|
|
|
print(self.board.pretty())
|
2018-02-06 22:29:51 +00:00
|
|
|
print(self.board.find_legal_moves(self.sym, roll[0]))
|
2018-02-05 22:50:31 +00:00
|
|
|
moves_1 = self.board.find_legal_moves(self.sym,roll[0])
|
|
|
|
move = random.choice(moves_1)
|
2018-02-06 22:29:51 +00:00
|
|
|
print("{} was picked as move".format(move))
|
2018-02-05 22:50:31 +00:00
|
|
|
self.board.move_thing(self.sym, int(move[0]), int(move[1]))
|
|
|
|
|
2018-02-07 15:27:03 +00:00
|
|
|
print(self.board.pretty())
|
2018-02-06 22:29:51 +00:00
|
|
|
print(self.board.find_legal_moves(self.sym, roll[1]))
|
2018-02-05 22:50:31 +00:00
|
|
|
moves_2 = self.board.find_legal_moves(self.sym,roll[1])
|
2018-02-06 22:29:51 +00:00
|
|
|
move = random.choice(moves_2)
|
|
|
|
print("{} was picked as move".format(move))
|
2018-02-05 22:50:31 +00:00
|
|
|
self.board.move_thing(self.sym, int(move[0]), int(move[1]))
|
2018-02-06 22:29:51 +00:00
|
|
|
|
|
|
|
|
2018-02-05 22:50:31 +00:00
|
|
|
|
|
|
|
|