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

StateとWMoveを保持する. More...

#include <openingBook.h>

List of all members.

Public Types

typedef vector< WMoveWMoveContainer

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

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

Definition at line 201 of file openingBook.h.


Constructor & Destructor Documentation

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.


Member Function Documentation

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().

Definition at line 150 of file openingBook.cc.

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::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:
stateto 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:
movesto apply
Returns:
state index; if it is not found, return -1.

Definition at line 281 of file openingBook.cc.

Definition at line 215 of file openingBook.h.

References nStates.

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

void osl::record::opening::WeightedBook::seek ( int  offset) [private]

Definition at line 124 of file openingBook.cc.


Member Data Documentation

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.

Definition at line 197 of file openingBook.h.

Referenced by WeightedBook().

Definition at line 196 of file openingBook.h.

Referenced by getTotalState(), and WeightedBook().

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.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines