2018-02-05 22:50:31 +00:00
|
|
|
from cup import Cup
|
2018-02-13 13:38:49 +00:00
|
|
|
from board import Board
|
2018-02-05 22:50:31 +00:00
|
|
|
import random
|
|
|
|
|
|
|
|
class Bot:
|
|
|
|
|
2018-02-13 13:38:49 +00:00
|
|
|
def __init__(self, sym):
|
2018-02-05 22:50:31 +00:00
|
|
|
self.cup = Cup()
|
|
|
|
self.sym = sym
|
|
|
|
|
|
|
|
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-13 13:38:49 +00:00
|
|
|
def do_move(board, roll):
|
|
|
|
print(Board.pretty(board))
|
|
|
|
print(Board.find_legal_moves(board, self.sym, roll[0]))
|
|
|
|
moves_1 = Board.find_legal_moves(board, self.sym,roll[0])
|
2018-02-05 22:50:31 +00:00
|
|
|
move = random.choice(moves_1)
|
2018-02-06 22:29:51 +00:00
|
|
|
print("{} was picked as move".format(move))
|
2018-02-13 13:38:49 +00:00
|
|
|
new_board = Board.move_thing(self.sym, int(move[0]), int(move[1]))
|
2018-02-05 22:50:31 +00:00
|
|
|
|
2018-02-13 13:38:49 +00:00
|
|
|
print(Board.pretty(new_board))
|
|
|
|
print(Board.find_legal_moves(new_board, self.sym, roll[1]))
|
|
|
|
moves_2 = Board.find_legal_moves(new_board, 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-13 13:38:49 +00:00
|
|
|
return Board.move_thing(new_board, self.sym, int(move[0]), int(move[1]))
|
2018-02-06 22:29:51 +00:00
|
|
|
|
|
|
|
|
2018-02-05 22:50:31 +00:00
|
|
|
|
|
|
|
|