static int move_value(int move, const board_t * board, int height, int trans_killer, int ThreadId) { int value; ASSERT(move_is_ok(move)); ASSERT(board!=NULL); ASSERT(height_is_ok(height)); ASSERT(trans_killer==MoveNone||move_is_ok(trans_killer)); if (false) { } else if (move == trans_killer) { // transposition table killer value = TransScore; } else if (move_is_tactical(move,board)) { // capture or promote value = capture_value(move,board); } else if (move == Killer[ThreadId][height][0]) { // killer 1 value = KillerScore; } else if (move == Killer[ThreadId][height][1]) { // killer 2 value = KillerScore - 2; } else if (height > 2 && move == Killer[ThreadId][height-2][0]) { // killer 1 value = KillerScore - 1; } else if (height > 2 && move == Killer[ThreadId][height-2][1]) { // killer 2 value = KillerScore - 3; } else { // quiet move value = quiet_move_value(move,board,ThreadId); } return value; }
bool lua_details::list_table(lua_State* L, int idx, TableInfo& out, int recursive) { out.clear(); if (lua_type(L, idx) != LUA_TTABLE) return false; int size= lua_objlen(L, idx); out.reserve(size); // table to traverse lua_pushvalue(L, idx); // push a key lua_pushnil(L); pop_stack_elements pop(L, 2); // remove key & table off the stack at the end of this fn // pop_stack_elements pop(L, 1); // remove table off the stack at the end of this fn int table= lua_gettop(L) - 1; // traverse a table while (lua_next(L, table)) { pop_stack_elements pop(L, 1); LuaField field; capture_value(L, field.key, -2); capture_value(L, field.val, -1, recursive); out.push_back(field); } pop.dec(); // final lua_next call removed key return true; }
static void note_captures(list_t * list, const board_t * board) { int size; int i, move; ASSERT(list_is_ok(list)); ASSERT(board!=NULL); size = LIST_SIZE(list); if (size >= 2) { for (i = 0; i < size; i++) { move = LIST_MOVE(list,i); list->value[i] = capture_value(move,board); } } }
bool lua_details::list_virtual_stack(lua_State* L, ValueStack& stack, size_t table_size_limit) { int size= lua_gettop(L); stack.clear(); stack.reserve(size); for (int idx= size - 1; idx > 0; --idx) { Value v; capture_value(L, v, idx, 1, table_size_limit); stack.push_back(v); } return true; }