35 lines
848 B
Python
35 lines
848 B
Python
|
from cup import Cup
|
||
|
import random
|
||
|
|
||
|
class Bot:
|
||
|
|
||
|
def __init__(self, board, sym):
|
||
|
self.cup = Cup()
|
||
|
self.board = board
|
||
|
self.sym = sym
|
||
|
|
||
|
def roll(self):
|
||
|
print("{} rolled: ".format(self.sym))
|
||
|
roll = self.cup.roll()
|
||
|
print(roll)
|
||
|
return roll
|
||
|
|
||
|
|
||
|
def switch(self,cur):
|
||
|
return "X" if cur == "O" else "O"
|
||
|
|
||
|
def do_move(self, roll):
|
||
|
print(self.board.to_s())
|
||
|
|
||
|
moves_1 = self.board.find_legal_moves(self.sym,roll[0])
|
||
|
move = random.choice(moves_1)
|
||
|
self.board.move_thing(self.sym, int(move[0]), int(move[1]))
|
||
|
|
||
|
print(self.board.to_s())
|
||
|
|
||
|
moves_2 = self.board.find_legal_moves(self.sym,roll[1])
|
||
|
omove = random.choice(moves_2)
|
||
|
self.board.move_thing(self.sym, int(move[0]), int(move[1]))
|
||
|
|
||
|
|