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. More... | |
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. More... | |
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. More... | |
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. More... | |
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 116 of file openingBook.cc.
References ifs, n_moves, n_states, osl::book::readInt(), start_state, and ~WeightedBook().
Referenced by osl::book::operator>>().
osl::book::WeightedBook::~WeightedBook | ( | ) |
int osl::book::WeightedBook::blackWinCount | ( | int | stateIndex | ) |
Definition at line 194 of file openingBook.cc.
References HEADER_SIZE, ifs, osl::book::readInt(), seek(), STATE_SIZE, and validate().
Referenced by osl::book::BookInMemory::readRecursive(), and whiteWinCount().
osl::SimpleState osl::book::WeightedBook::board | ( | int | stateIndex | ) |
Definition at line 177 of file openingBook.cc.
References compactBoard(), osl::book::CompactBoard::state(), and whiteWinCount().
Referenced by compactBoard(), and validate().
osl::book::CompactBoard osl::book::WeightedBook::compactBoard | ( | int | stateIndex | ) |
Definition at line 167 of file openingBook.cc.
References board(), BOARD_SIZE, HEADER_SIZE, ifs, MOVE_SIZE, n_moves, n_states, seek(), and STATE_SIZE.
Referenced by board(), moves(), and stateIndex().
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 147 of file openingBook.cc.
References compactBoard(), HEADER_SIZE, ifs, MOVE_SIZE, n_states, osl::book::readInt(), seek(), and STATE_SIZE.
Referenced by parents(), osl::book::BookInMemory::readRecursive(), seek(), stateIndex(), and validate().
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 318 of file openingBook.cc.
References moves(), startState(), stateIndex(), and totalState().
Referenced by stateIndex().
|
private |
Definition at line 141 of file openingBook.cc.
Referenced by blackWinCount(), compactBoard(), moves(), whiteWinCount(), and ~WeightedBook().
|
inline |
Definition at line 190 of file openingBook.h.
References osl::BLACK, and osl::book::OMove::player().
Referenced by parents(), osl::book::BookInMemory::readAll(), and stateIndex().
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 242 of file openingBook.cc.
References compactBoard(), moves(), parents(), start_state, startState(), totalState(), and osl::book::CompactBoard::turn().
Referenced by parents(), and validate().
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.
Referenced by parents(), and stateIndex().
void osl::book::WeightedBook::validate | ( | ) |
Definition at line 203 of file openingBook.cc.
References board(), osl::HIRATE, osl::NumEffectState::makeMove(), moves(), n_states, start_state, and stateIndex().
Referenced by blackWinCount().
int osl::book::WeightedBook::whiteWinCount | ( | int | stateIndex | ) |
Definition at line 184 of file openingBook.cc.
References blackWinCount(), HEADER_SIZE, ifs, osl::book::readInt(), seek(), and STATE_SIZE.
Referenced by board(), and osl::book::BookInMemory::readRecursive().
|
staticprivate |
Definition at line 226 of file openingBook.h.
Referenced by compactBoard().
|
staticprivate |
Definition at line 223 of file openingBook.h.
Referenced by blackWinCount(), compactBoard(), moves(), and whiteWinCount().
|
private |
Definition at line 173 of file openingBook.h.
Referenced by blackWinCount(), compactBoard(), moves(), seek(), WeightedBook(), and whiteWinCount().
|
staticprivate |
Definition at line 225 of file openingBook.h.
Referenced by compactBoard(), and moves().
|
private |
Definition at line 171 of file openingBook.h.
Referenced by compactBoard(), and WeightedBook().
|
private |
Definition at line 170 of file openingBook.h.
Referenced by compactBoard(), moves(), validate(), and WeightedBook().
|
private |
Definition at line 172 of file openingBook.h.
Referenced by stateIndex(), validate(), and WeightedBook().
|
staticprivate |
Definition at line 224 of file openingBook.h.
Referenced by blackWinCount(), compactBoard(), moves(), and whiteWinCount().