osl::record::opening::WeightedBook Class Reference

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
osl::record::opening::WeightedBook Class Reference

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. More...
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. More...
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. More...
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. More...

## 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

## Detailed Description

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.

## Member Typedef Documentation

typedef vector<WMove> osl::record::opening::WeightedBook::WMoveContainer

Definition at line 201 of file openingBook.h.

## Constructor & Destructor Documentation

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.

osl::record::opening::WeightedBook::~WeightedBook | ( | ) |  |

Definition at line 119 of file openingBook.cc.

## Member Function Documentation

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.

Returns
  state indexes; empty if there is none.

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.

Parameters

  state | to find
  visit_zero |
  player |

Returns
  a state index of the state; if it is not found, return -1.

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.

Parameters

  moves | to apply

Returns
  state index; if it is not found, return -1.

Definition at line 281 of file openingBook.cc.

int osl::record::opening::WeightedBook::getTotalState | ( | ) |  | const
| inline

Definition at line 215 of file openingBook.h.

References nStates.

Referenced by doMain(), main(), and store().

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.

void osl::record::opening::WeightedBook::validate | ( | ) |  |

Definition at line 186 of file openingBook.cc.

References osl::record::opening::WMove::getMove(), osl::record::opening::WMove::getStateIndex(), osl::HIRATE, and moves.

## Member Data Documentation

const int osl::record::opening::WeightedBook::BOARD_SIZE = 41 * 4
| staticprivate

Definition at line 252 of file openingBook.h.

const int osl::record::opening::WeightedBook::HEADER_SIZE = 16
| staticprivate

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
| staticprivate

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
| staticprivate

Definition at line 250 of file openingBook.h.

The documentation for this class was generated from the following files:

- openingBook.h
- openingBook.cc