41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
from board import Board
|
|
|
|
import numpy as np
|
|
import pubeval
|
|
import dumbeval
|
|
|
|
|
|
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(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
|
|
|
|
@staticmethod
|
|
def make_dumbeval_move(board, sym, roll):
|
|
legal_moves = Board.calculate_legal_states(board, sym, roll)
|
|
moves_and_scores = [ ( board,
|
|
dumbeval.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
|
|
|
|
|