My Project
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
osl::book::WeightedBook Class Reference

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

#include <openingBook.h>

Public Types

typedef std::vector< WMoveWMoveContainer
 

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
 

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数

Definition at line 168 of file openingBook.h.

Member Typedef Documentation

◆ WMoveContainer

Definition at line 175 of file openingBook.h.

Constructor & Destructor Documentation

◆ WeightedBook()

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.

◆ ~WeightedBook()

osl::book::WeightedBook::~WeightedBook ( )

Definition at line 135 of file openingBook.cc.

Member Function Documentation

◆ blackWinCount()

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

◆ board()

osl::SimpleState osl::book::WeightedBook::board ( int  stateIndex)

Definition at line 176 of file openingBook.cc.

References osl::book::CompactBoard::state().

◆ compactBoard()

osl::book::CompactBoard osl::book::WeightedBook::compactBoard ( int  stateIndex)

Definition at line 166 of file openingBook.cc.

◆ moves()

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

◆ parents()

std::vector< int > osl::book::WeightedBook::parents ( 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 317 of file openingBook.cc.

◆ seek()

void osl::book::WeightedBook::seek ( int  offset)
private

Definition at line 140 of file openingBook.cc.

◆ startState()

int osl::book::WeightedBook::startState ( ) const
inline

Definition at line 190 of file openingBook.h.

References start_state.

Referenced by osl::book::BookInMemory::readAll().

◆ stateIndex() [1/2]

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.

Parameters
stateto find
visit_zero
player
Returns
a state index of the state; if it is not found, return -1.

Definition at line 241 of file openingBook.cc.

References osl::book::CompactBoard::turn().

◆ stateIndex() [2/2]

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.

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

◆ totalState()

int osl::book::WeightedBook::totalState ( ) const
inline

Definition at line 189 of file openingBook.h.

References n_states.

◆ validate()

void osl::book::WeightedBook::validate ( )

Definition at line 202 of file openingBook.cc.

References osl::HIRATE, and osl::NumEffectState::makeMove().

◆ whiteWinCount()

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

Member Data Documentation

◆ BOARD_SIZE

const int osl::book::WeightedBook::BOARD_SIZE = 41 * 4
staticprivate

Definition at line 226 of file openingBook.h.

◆ HEADER_SIZE

const int osl::book::WeightedBook::HEADER_SIZE = 16
staticprivate

Definition at line 223 of file openingBook.h.

◆ ifs

std::ifstream osl::book::WeightedBook::ifs
private

Definition at line 173 of file openingBook.h.

Referenced by WeightedBook().

◆ MOVE_SIZE

const int osl::book::WeightedBook::MOVE_SIZE = 12
staticprivate

Definition at line 225 of file openingBook.h.

◆ n_moves

int osl::book::WeightedBook::n_moves
private

Definition at line 171 of file openingBook.h.

Referenced by WeightedBook().

◆ n_states

int osl::book::WeightedBook::n_states
private

Definition at line 170 of file openingBook.h.

Referenced by totalState(), and WeightedBook().

◆ start_state

int osl::book::WeightedBook::start_state
private

Definition at line 172 of file openingBook.h.

Referenced by startState(), and WeightedBook().

◆ STATE_SIZE

const int osl::book::WeightedBook::STATE_SIZE = 16
staticprivate

Definition at line 224 of file openingBook.h.


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