StateとWMoveを保持する. More...
#include <openingBook.h>
Public Types | |
typedef vector< WMove > | WMoveContainer |
Public Member Functions | |
WeightedBook (const char *filename) | |
~WeightedBook () | |
WMoveContainer | getMoves (int stateIndex, const bool zero_include=true) |
Return moves from the state of the stateIndex. | |
int | getWhiteWinCount (int stateIndex) |
int | getBlackWinCount (int stateIndex) |
osl::record::CompactBoard | getCompactBoard (int stateIndex) |
SimpleState | getBoard (int stateIndex) |
int | getTotalState () const |
int | getStartState () const |
void | validate () |
std::vector< int > | getParents (const int stateIndex) |
As traversing the 'tree', return all state indices of the state's parents. | |
int | getStateIndex (const SimpleState &state, const bool visit_zero=true, const Player player=BLACK) |
As traversing the 'tree', find a state index of the state. | |
int | getStateIndex (const vector< Move > &moves) |
As traversing the 'tree', find a state index of the state reached by applying the moves from the initial state. | |
Private Member Functions | |
void | seek (int offset) |
Private Attributes | |
int | nStates |
int | nMoves |
int | startState |
std::ifstream | ifs |
Static Private Attributes | |
static const int | HEADER_SIZE = 16 |
static const int | STATE_SIZE = 16 |
static const int | MOVE_SIZE = 12 |
static const int | BOARD_SIZE = 41 * 4 |
StateとWMoveを保持する.
Stateはvector<WMove>を保持する WMoveはMoveとそのMoveを採用した時のStateのindexと手番から見た Moveの重み(0-1000)をもつ ファイル形式 version番号 - 4byte state数 - 4byte move数 - 4byte 開始state index - 4byte State - 16byte * state数 + WMoveの開始index + WMoveの数 + 先手の勝数 + 後手の勝数 WMove - 12byte * WMove数 + Move (4byte) + Stateのindex + Weight CompactBoard形式の盤面 - 164byte * state数
Definition at line 194 of file openingBook.h.
typedef vector<WMove> osl::record::opening::WeightedBook::WMoveContainer |
Definition at line 201 of file openingBook.h.
osl::record::opening::WeightedBook::WeightedBook | ( | const char * | filename | ) |
Definition at line 99 of file openingBook.cc.
References ifs, nMoves, nStates, osl::record::readInt(), and startState.
Definition at line 119 of file openingBook.cc.
int osl::record::opening::WeightedBook::getBlackWinCount | ( | int | stateIndex | ) |
Definition at line 177 of file openingBook.cc.
References osl::record::readInt().
Referenced by osl::record::opening::BookInMemory::readRecursive(), show_moves(), and showInfoOfState().
osl::SimpleState osl::record::opening::WeightedBook::getBoard | ( | int | stateIndex | ) |
Definition at line 160 of file openingBook.cc.
References osl::record::CompactBoard::getState().
Referenced by doMain(), dump(), main(), showInfoOfState(), and store().
osl::record::CompactBoard osl::record::opening::WeightedBook::getCompactBoard | ( | int | stateIndex | ) |
Definition at line 150 of file openingBook.cc.
osl::record::opening::WeightedBook::WMoveContainer osl::record::opening::WeightedBook::getMoves | ( | int | stateIndex, |
const bool | zero_include = true |
||
) |
Return moves from the state of the stateIndex.
If the zero_include is true, all of the moves are returned. Otherwise, the moves that have some weights (i.e. non-zero value) are returned.
Definition at line 130 of file openingBook.cc.
References moves, and osl::record::readInt().
Referenced by doMain(), increment(), is_same_node(), main(), make_history(), osl::record::opening::BookInMemory::readRecursive(), osl::game_playing::WinCountTracer::selectMove(), osl::game_playing::WeightTracer::selectMove(), osl::game_playing::DeterminateWeightTracer::selectMove(), show_moves(), showInfoOfState(), store(), osl::game_playing::WinCountTracer::update(), and osl::game_playing::WeightTracer::update().
std::vector< int > osl::record::opening::WeightedBook::getParents | ( | const int | stateIndex | ) |
As traversing the 'tree', return all state indices of the state's parents.
Definition at line 302 of file openingBook.cc.
References osl::record::opening::WMove::getStateIndex(), and moves.
Referenced by doMain().
int osl::record::opening::WeightedBook::getStartState | ( | ) | const [inline] |
Definition at line 216 of file openingBook.h.
References startState.
Referenced by doMain(), increment(), main(), make_history(), osl::record::opening::BookInMemory::readAll(), and store().
int osl::record::opening::WeightedBook::getStateIndex | ( | const SimpleState & | state, |
const bool | visit_zero = true , |
||
const Player | player = BLACK |
||
) |
As traversing the 'tree', find a state index of the state.
If the visit_zero is true zero-weighted moves are visited (in this case, player is ignored). Otherwise, the palyer's zero-weighted moves are not visited.
state | to find |
visit_zero | |
player |
Definition at line 226 of file openingBook.cc.
References osl::record::opening::WMove::getStateIndex(), moves, and osl::record::CompactBoard::turn().
Referenced by doMain().
int osl::record::opening::WeightedBook::getStateIndex | ( | const vector< Move > & | moves | ) |
As traversing the 'tree', find a state index of the state reached by applying the moves from the initial state.
Note that zero-weighted moves are visited.
moves | to apply |
Definition at line 281 of file openingBook.cc.
int osl::record::opening::WeightedBook::getTotalState | ( | ) | const [inline] |
int osl::record::opening::WeightedBook::getWhiteWinCount | ( | int | stateIndex | ) |
Definition at line 167 of file openingBook.cc.
References osl::record::readInt().
Referenced by osl::record::opening::BookInMemory::readRecursive(), show_moves(), and showInfoOfState().
void osl::record::opening::WeightedBook::seek | ( | int | offset | ) | [private] |
Definition at line 124 of file openingBook.cc.
Definition at line 186 of file openingBook.cc.
References osl::record::opening::WMove::getMove(), osl::record::opening::WMove::getStateIndex(), osl::HIRATE, and moves.
const int osl::record::opening::WeightedBook::BOARD_SIZE = 41 * 4 [static, private] |
Definition at line 252 of file openingBook.h.
const int osl::record::opening::WeightedBook::HEADER_SIZE = 16 [static, private] |
Definition at line 249 of file openingBook.h.
std::ifstream osl::record::opening::WeightedBook::ifs [private] |
Definition at line 199 of file openingBook.h.
Referenced by WeightedBook().
const int osl::record::opening::WeightedBook::MOVE_SIZE = 12 [static, private] |
Definition at line 251 of file openingBook.h.
int osl::record::opening::WeightedBook::nMoves [private] |
Definition at line 197 of file openingBook.h.
Referenced by WeightedBook().
int osl::record::opening::WeightedBook::nStates [private] |
Definition at line 196 of file openingBook.h.
Referenced by getTotalState(), and WeightedBook().
int osl::record::opening::WeightedBook::startState [private] |
Definition at line 198 of file openingBook.h.
Referenced by getStartState(), and WeightedBook().
const int osl::record::opening::WeightedBook::STATE_SIZE = 16 [static, private] |
Definition at line 250 of file openingBook.h.