add "race" parameter to pubeval
This commit is contained in:
parent
4b907d30cf
commit
b7e7b52e7c
2
bot.py
2
bot.py
|
@ -52,7 +52,7 @@ class Bot:
|
|||
# TODO: Test this, the score results should be deterministic
|
||||
def make_pubeval_move(self, board, sym, roll):
|
||||
legal_moves = Board.calculate_legal_states(tuple(board), sym, roll)
|
||||
moves_and_scores = [(board, pubeval.eval(board)) for board in legal_moves]
|
||||
moves_and_scores = [(board, pubeval.eval(False, board)) 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
|
||||
|
|
|
@ -126,17 +126,17 @@ float pubeval(int race, int pos[])
|
|||
|
||||
static PyObject*
|
||||
pubeval_eval(PyObject *self, PyObject *args) {
|
||||
int race;
|
||||
long numValues;
|
||||
int board[28];
|
||||
float eval_score;
|
||||
|
||||
PyObject* tuple_obj;
|
||||
PyObject* val_obj;
|
||||
PyObject* return_obj;
|
||||
|
||||
if (! PyArg_ParseTuple(args, "O!", &PyTuple_Type, &tuple_obj))
|
||||
if (! PyArg_ParseTuple(args, "pO!", &race, &PyTuple_Type, &tuple_obj))
|
||||
return NULL;
|
||||
|
||||
|
||||
numValues = PyTuple_Size(tuple_obj);
|
||||
|
||||
if (numValues < 0) return NULL;
|
||||
|
@ -147,9 +147,8 @@ pubeval_eval(PyObject *self, PyObject *args) {
|
|||
board[i] = PyLong_AsLong(val_obj);
|
||||
}
|
||||
|
||||
eval_score = pubeval(0, board);
|
||||
return_obj = Py_BuildValue("f", eval_score);
|
||||
return return_obj;
|
||||
eval_score = pubeval(race, board);
|
||||
return Py_BuildValue("f", eval_score);
|
||||
}
|
||||
|
||||
static PyMethodDef pubeval_methods[] = {
|
||||
|
|
|
@ -4,6 +4,6 @@ pubeval = Extension('pubeval',
|
|||
sources = ['pubeval.c'])
|
||||
|
||||
setup (name = 'pubeval',
|
||||
version = '0.1',
|
||||
version = '0.2',
|
||||
description = 'Pubeval for Python',
|
||||
ext_modules = [pubeval])
|
||||
|
|
Loading…
Reference in New Issue
Block a user