29 lines
614 B
Python
29 lines
614 B
Python
from cup import Cup
|
|
from board import Board
|
|
import random
|
|
|
|
class Bot:
|
|
|
|
def __init__(self, sym):
|
|
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):
|
|
return -1 if cur == 1 else 1
|
|
|
|
def get_sym(self):
|
|
return self.sym
|
|
|
|
def make_move(self, board, sym, roll):
|
|
# print(Board.pretty(board))
|
|
legal_moves = Board.calculate_legal_states(board, sym, roll)
|
|
|
|
return random.choice(list(legal_moves))
|