My Project
|
StateとWMoveを保持する. More...
#include <openingBook.h>
Public Types | |
typedef std::vector< WMove > | WMoveContainer |
Public Member Functions | |
WeightedBook (const char *filename) | |
~WeightedBook () | |
WMoveContainer | moves (int stateIndex, const bool zero_include=true) |
Return moves from the state of the stateIndex. | |
int | whiteWinCount (int stateIndex) |
int | blackWinCount (int stateIndex) |
CompactBoard | compactBoard (int stateIndex) |
SimpleState | board (int stateIndex) |
int | totalState () const |
int | startState () const |
void | validate () |
std::vector< int > | parents (const int stateIndex) |
As traversing the 'tree', return all state indices of the state's parents. | |
int | stateIndex (const SimpleState &state, const bool visit_zero=true, const Player player=BLACK) |
As traversing the 'tree', find a state index of the state. | |
int | stateIndex (const std::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 | n_states |
int | n_moves |
int | start_state |
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数
Definition at line 168 of file openingBook.h.
typedef std::vector<WMove> osl::book::WeightedBook::WMoveContainer |
Definition at line 175 of file openingBook.h.
osl::book::WeightedBook::WeightedBook | ( | const char * | filename | ) |
Definition at line 115 of file openingBook.cc.
References ifs, n_moves, n_states, osl::book::readInt(), and start_state.
osl::book::WeightedBook::~WeightedBook | ( | ) |
Definition at line 135 of file openingBook.cc.
int osl::book::WeightedBook::blackWinCount | ( | int | stateIndex | ) |
Definition at line 193 of file openingBook.cc.
References osl::book::readInt().
Referenced by osl::book::BookInMemory::readRecursive().
osl::SimpleState osl::book::WeightedBook::board | ( | int | stateIndex | ) |
Definition at line 176 of file openingBook.cc.
References osl::book::CompactBoard::state().
osl::book::CompactBoard osl::book::WeightedBook::compactBoard | ( | int | stateIndex | ) |
Definition at line 166 of file openingBook.cc.
osl::book::WeightedBook::WMoveContainer osl::book::WeightedBook::moves | ( | 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 146 of file openingBook.cc.
References osl::book::readInt(), and osl::book::WMove::weight.
Referenced by osl::book::BookInMemory::readRecursive().
std::vector< int > osl::book::WeightedBook::parents | ( | const int | stateIndex | ) |
As traversing the 'tree', return all state indices of the state's parents.
Definition at line 317 of file openingBook.cc.
|
private |
Definition at line 140 of file openingBook.cc.
|
inline |
Definition at line 190 of file openingBook.h.
References start_state.
Referenced by osl::book::BookInMemory::readAll().
int osl::book::WeightedBook::stateIndex | ( | 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 241 of file openingBook.cc.
References osl::book::CompactBoard::turn().
int osl::book::WeightedBook::stateIndex | ( | const std::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 |
|
inline |
Definition at line 189 of file openingBook.h.
References n_states.
void osl::book::WeightedBook::validate | ( | ) |
Definition at line 202 of file openingBook.cc.
References osl::HIRATE, and osl::NumEffectState::makeMove().
int osl::book::WeightedBook::whiteWinCount | ( | int | stateIndex | ) |
Definition at line 183 of file openingBook.cc.
References osl::book::readInt().
Referenced by osl::book::BookInMemory::readRecursive().
|
staticprivate |
Definition at line 226 of file openingBook.h.
|
staticprivate |
Definition at line 223 of file openingBook.h.
|
private |
Definition at line 173 of file openingBook.h.
Referenced by WeightedBook().
|
staticprivate |
Definition at line 225 of file openingBook.h.
|
private |
Definition at line 171 of file openingBook.h.
Referenced by WeightedBook().
|
private |
Definition at line 170 of file openingBook.h.
Referenced by totalState(), and WeightedBook().
|
private |
Definition at line 172 of file openingBook.h.
Referenced by startState(), and WeightedBook().
|
staticprivate |
Definition at line 224 of file openingBook.h.