Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

BookUtil Namespace Reference

Utilities on Books. More...

Functions

float Value (const SgBookNode &node, const HexState &brd)
 Returns value of board, taking into account swap moves.
float Score (const SgBookNode &node, const HexState &brd, float countWeight)
 Returns score for this node, taking into account the amount of information in the subtree.
float InverseEval (float eval)
 Evaluation for other player.
HexPoint BestMove (const Book &book, const HexState &state, unsigned minCount, float countWeight)
 Finds best response in book.
void DumpVisualizationData (const Book &book, const HexState &state, int depth, std::ostream &out)
 Writes a (score, depth) pair to output stream for each leaf in the book.
void DumpPolarizedLeafs (const Book &book, const HexState &state, float polarization, PointSequence &pv, std::ostream &out, const StateSet &ignoreSet)
 Writes variations leading to non-terminal leafs whose values differ from 0.5 by at least polarization.
void ImportSolvedStates (Book &book, const ConstBoard &constBoard, std::istream &positions)
 Reads solved leaf positions from a file and adds them to the given book.
int GetMainLineDepth (const Book &book, const HexState &state)
 Returns the depth of the mainline from the given state.
std::size_t GetTreeSize (const Book &book, const HexState &state)
 Returns the number of nodes in the tree rooted at the current state.

Detailed Description

Utilities on Books.


Function Documentation

HexPoint BookUtil::BestMove ( const Book book,
const HexState state,
unsigned  minCount,
float  countWeight 
)

Finds best response in book.

Todo:
Does not consider SWAP_PIECES if it is available. Returns INVALID_POINT if not in book or if node's count is less than minCount.

Definition at line 125 of file Book.cpp.

References StateDB< T >::Get(), StoneBoard::GetEmpty(), HexAssert, INVALID_POINT, HexState::PlayMove(), HexState::Position(), Score(), and HexState::UndoMove().

void BookUtil::DumpPolarizedLeafs ( const Book book,
const HexState state,
float  polarization,
PointSequence pv,
std::ostream &  out,
const StateSet ignoreSet 
)

Writes variations leading to non-terminal leafs whose values differ from 0.5 by at least polarization.

The given pv must be the variation leading to the current state of the board.

Definition at line 216 of file Book.cpp.

References HexModState::State().

Referenced by BookCommands::CmdBookDumpPolarizedLeafs().

void BookUtil::DumpVisualizationData ( const Book book,
const HexState state,
int  depth,
std::ostream &  out 
)

Writes a (score, depth) pair to output stream for each leaf in the book.

Can be visualized with GnuPlot.

Definition at line 156 of file Book.cpp.

References StateDB< T >::Get(), StoneBoard::GetEmpty(), HexState::PlayMove(), HexState::Position(), HexModState::State(), HexState::UndoMove(), and Value().

Referenced by BookCommands::CmdBookVisualize().

int BookUtil::GetMainLineDepth ( const Book book,
const HexState state 
)

Returns the depth of the mainline from the given state.

Definition at line 58 of file Book.cpp.

References StateDB< T >::Get(), StoneBoard::GetEmpty(), INVALID_POINT, InverseEval(), HexState::PlayMove(), HexState::Position(), HexState::UndoMove(), and Value().

Referenced by BookCommands::CmdBookMainLineDepth().

std::size_t BookUtil::GetTreeSize ( const Book book,
const HexState state 
)

Returns the number of nodes in the tree rooted at the current state.

Definition at line 116 of file Book.cpp.

void BookUtil::ImportSolvedStates ( Book book,
const ConstBoard constBoard,
std::istream &  positions 
)

Reads solved leaf positions from a file and adds them to the given book.

Overwrites value of any existing states.

Definition at line 227 of file Book.cpp.

References BLACK, EMPTY, FIRST_TO_PLAY, StateDB< T >::Flush(), HexPointUtil::FromString(), StateDB< T >::Get(), ConstBoard::Height(), HexAssert, HexEval, IMMEDIATE_LOSS, IMMEDIATE_WIN, INVALID_POINT, LogInfo(), StateDB< T >::Put(), WHITE, and ConstBoard::Width().

Referenced by BookCommands::CmdBookImportSolvedStates().

float BookUtil::InverseEval ( float  eval  ) 
float BookUtil::Score ( const SgBookNode &  node,
const HexState brd,
float  countWeight 
)

Returns score for this node, taking into account the amount of information in the subtree.

Use to select moves when using book. Note the score is from the pov of the player moving into this position, not for the player to move in this position.

Definition at line 37 of file Book.cpp.

References InverseEval(), and Value().

Referenced by BestMove(), and BookCommands::CmdBookScores().

float BookUtil::Value ( const SgBookNode &  node,
const HexState brd 
)

Returns value of board, taking into account swap moves.

Definition at line 30 of file Book.cpp.

References InverseEval(), StoneBoard::IsLegal(), HexState::Position(), and SWAP_PIECES.

Referenced by BookCommands::CmdBookScores(), DumpVisualizationData(), GetMainLineDepth(), and Score().


6 Jan 2011 Doxygen 1.6.3