|
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 HEADER_SIZE, ifs, osl::book::readInt(), seek(), STATE_SIZE, and stateIndex().
| osl::SimpleState osl::book::WeightedBook::board | ( | int | stateIndex | ) |
Definition at line 176 of file openingBook.cc.
References board(), compactBoard(), and stateIndex().
Referenced by board(), compactBoard(), and validate().
| osl::book::CompactBoard osl::book::WeightedBook::compactBoard | ( | int | stateIndex | ) |
Definition at line 166 of file openingBook.cc.
References board(), BOARD_SIZE, HEADER_SIZE, ifs, MOVE_SIZE, n_moves, n_states, seek(), STATE_SIZE, and stateIndex().
Referenced by board(), 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 146 of file openingBook.cc.
References HEADER_SIZE, ifs, MOVE_SIZE, moves(), n_states, osl::book::readInt(), seek(), STATE_SIZE, stateIndex(), and osl::book::WMove::weight.
Referenced by moves(), parents(), stateIndex(), 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 317 of file openingBook.cc.
References moves(), startState(), stateIndex(), and totalState().
|
private |
Definition at line 140 of file openingBook.cc.
References ifs.
Referenced by blackWinCount(), compactBoard(), moves(), and whiteWinCount().
|
inline |
Definition at line 190 of file openingBook.h.
References start_state.
Referenced by parents(), 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 241 of file openingBook.cc.
References compactBoard(), moves(), start_state, startState(), stateIndex(), totalState(), and osl::book::CompactBoard::turn().
Referenced by blackWinCount(), board(), compactBoard(), moves(), parents(), stateIndex(), and whiteWinCount().
| 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 |
References moves().
|
inline |
Definition at line 189 of file openingBook.h.
References n_states.
Referenced by parents(), and stateIndex().
| void osl::book::WeightedBook::validate | ( | ) |
Definition at line 202 of file openingBook.cc.
References board(), osl::HIRATE, osl::NumEffectState::makeMove(), moves(), n_states, and start_state.
| int osl::book::WeightedBook::whiteWinCount | ( | int | stateIndex | ) |
Definition at line 183 of file openingBook.cc.
References HEADER_SIZE, ifs, osl::book::readInt(), seek(), STATE_SIZE, and stateIndex().
|
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(), totalState(), validate(), and WeightedBook().
|
private |
Definition at line 172 of file openingBook.h.
Referenced by startState(), stateIndex(), validate(), and WeightedBook().
|
staticprivate |
Definition at line 224 of file openingBook.h.
Referenced by blackWinCount(), compactBoard(), moves(), and whiteWinCount().