add "race" parameter to pubeval

This commit is contained in:
Christoffer Müller Madsen 2018-03-14 11:44:46 +01:00
parent 4b907d30cf
commit b7e7b52e7c
Signed by: christoffer
GPG Key ID: 337BA5A95E686EFD
3 changed files with 7 additions and 8 deletions

2
bot.py
View File

@ -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

View File

@ -126,15 +126,15 @@ 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);
@ -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[] = {

View File

@ -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])