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
|
# TODO: Test this, the score results should be deterministic
|
||||||
def make_pubeval_move(self, board, sym, roll):
|
def make_pubeval_move(self, board, sym, roll):
|
||||||
legal_moves = Board.calculate_legal_states(tuple(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 ]
|
scores = [ x[1] for x in moves_and_scores ]
|
||||||
best_move_pair = moves_and_scores[np.array(scores).argmax()]
|
best_move_pair = moves_and_scores[np.array(scores).argmax()]
|
||||||
return best_move_pair
|
return best_move_pair
|
||||||
|
|
|
@ -126,15 +126,15 @@ float pubeval(int race, int pos[])
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
pubeval_eval(PyObject *self, PyObject *args) {
|
pubeval_eval(PyObject *self, PyObject *args) {
|
||||||
|
int race;
|
||||||
long numValues;
|
long numValues;
|
||||||
int board[28];
|
int board[28];
|
||||||
float eval_score;
|
float eval_score;
|
||||||
|
|
||||||
PyObject* tuple_obj;
|
PyObject* tuple_obj;
|
||||||
PyObject* val_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;
|
return NULL;
|
||||||
|
|
||||||
numValues = PyTuple_Size(tuple_obj);
|
numValues = PyTuple_Size(tuple_obj);
|
||||||
|
@ -147,9 +147,8 @@ pubeval_eval(PyObject *self, PyObject *args) {
|
||||||
board[i] = PyLong_AsLong(val_obj);
|
board[i] = PyLong_AsLong(val_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
eval_score = pubeval(0, board);
|
eval_score = pubeval(race, board);
|
||||||
return_obj = Py_BuildValue("f", eval_score);
|
return Py_BuildValue("f", eval_score);
|
||||||
return return_obj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef pubeval_methods[] = {
|
static PyMethodDef pubeval_methods[] = {
|
||||||
|
|
|
@ -4,6 +4,6 @@ pubeval = Extension('pubeval',
|
||||||
sources = ['pubeval.c'])
|
sources = ['pubeval.c'])
|
||||||
|
|
||||||
setup (name = 'pubeval',
|
setup (name = 'pubeval',
|
||||||
version = '0.1',
|
version = '0.2',
|
||||||
description = 'Pubeval for Python',
|
description = 'Pubeval for Python',
|
||||||
ext_modules = [pubeval])
|
ext_modules = [pubeval])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user