22 lines
745 B
Python
22 lines
745 B
Python
from board import Board
|
|
|
|
import numpy as np
|
|
import pubeval
|
|
|
|
|
|
class Eval:
|
|
@staticmethod
|
|
def make_random_move(board, sym, roll):
|
|
legal_moves = Board.calculate_legal_states(board, sym, roll)
|
|
return random.choice(list(legal_moves))
|
|
|
|
|
|
# TODO: Test this, the score results should be deterministic
|
|
@staticmethod
|
|
def make_pubeval_move(board, sym, roll):
|
|
legal_moves = Board.calculate_legal_states(tuple(board), sym, roll)
|
|
moves_and_scores = [(board, pubeval.eval(False, Board.board_features_to_pubeval(board, sym))) for board in legal_moves]
|
|
scores = [ x[1] for x in moves_and_scores ]
|
|
best_move_pair = moves_and_scores[np.array(scores).argmax()]
|
|
return best_move_pair
|