Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes

GoAutoBook Class Reference

Simple text-based book format. More...

#include <GoAutoBook.h>

List of all members.

Public Member Functions

 GoAutoBook (const std::string &filename, const GoAutoBookParam &param)
 ~GoAutoBook ()
bool Get (const GoAutoBookState &state, SgBookNode &node) const
 Read the node at the given state.
void Put (const GoAutoBookState &state, const SgBookNode &node)
 Store the node in the given state.
void Flush ()
 Since there is no cache, same as Save().
void Save (const std::string &filename) const
 Writes book to disk.
SgMove LookupMove (const GoBoard &brd) const
 Helper function: calls FindBestChild() on the given board.
SgMove FindBestChild (GoAutoBookState &state) const
 Returns the move leading to the best child state.
void Merge (const GoAutoBook &other)
 Merge this book with given book.
void AddDisabledLines (const std::set< SgHashCode > &disabled)
 Add states to be disabled.
void TruncateByDepth (int depth, GoAutoBookState &state, GoAutoBook &other) const
 Copies a truncated version of the book into other.
void ImportHashValuePairs (std::istream &in)
 Overwrites values in book by reading stream of (hash, value) pairs.
void ExportToOldFormat (GoAutoBookState &state, std::ostream &os) const
 Exports book states under the given state in GoBook format to the given stream.

Static Public Member Functions

static std::vector
< std::vector< SgMove > > 
ParseWorkList (std::istream &in)
 Parses a worklist from a stream.

Private Types

typedef std::map< SgHashCode,
SgBookNode
Map

Private Member Functions

void TruncateByDepth (int depth, GoAutoBookState &state, GoAutoBook &other, std::set< SgHashCode > &seen) const
void ExportToOldFormat (GoAutoBookState &state, std::ostream &out, std::set< SgHashCode > &seen) const

Private Attributes

Map m_data
const GoAutoBookParamm_param
std::set< SgHashCodem_disabled
std::string m_filename

Detailed Description

Simple text-based book format.

Entire book is loaded into memory.

Definition at line 88 of file GoAutoBook.h.


Member Typedef Documentation

typedef std::map<SgHashCode, SgBookNode> GoAutoBook::Map [private]

Definition at line 152 of file GoAutoBook.h.


Constructor & Destructor Documentation

GoAutoBook::GoAutoBook ( const std::string &  filename,
const GoAutoBookParam param 
)

Definition at line 78 of file GoAutoBook.cpp.

References SgHash< N >::FromString(), m_data, and SgDebug().

GoAutoBook::~GoAutoBook (  ) 

Definition at line 111 of file GoAutoBook.cpp.


Member Function Documentation

void GoAutoBook::AddDisabledLines ( const std::set< SgHashCode > &  disabled  ) 

Add states to be disabled.

These states will not be considered for selection in FindBestChild() from the parent state.

Definition at line 171 of file GoAutoBook.h.

References m_disabled, and SgDebug().

void GoAutoBook::ExportToOldFormat ( GoAutoBookState state,
std::ostream &  os 
) const

Exports book states under the given state in GoBook format to the given stream.

Only the move that would be selected with FindBestMove() is given as an option in each state.

Definition at line 378 of file GoAutoBook.cpp.

Referenced by ExportToOldFormat().

void GoAutoBook::ExportToOldFormat ( GoAutoBookState state,
std::ostream &  out,
std::set< SgHashCode > &  seen 
) const [private]
SgMove GoAutoBook::FindBestChild ( GoAutoBookState state  )  const
void GoAutoBook::Flush (  ) 

Since there is no cache, same as Save().

Definition at line 131 of file GoAutoBook.cpp.

References m_filename, and Save().

bool GoAutoBook::Get ( const GoAutoBookState state,
SgBookNode node 
) const

Read the node at the given state.

Returns true if node exists in the book, and false otherwise.

Definition at line 115 of file GoAutoBook.cpp.

References GoAutoBookState::GetHashCode(), and m_data.

Referenced by ExportToOldFormat(), FindBestChild(), and TruncateByDepth().

void GoAutoBook::ImportHashValuePairs ( std::istream &  in  ) 

Overwrites values in book by reading stream of (hash, value) pairs.

Definition at line 249 of file GoAutoBook.cpp.

References SgHash< N >::FromString(), m_data, SgBookNode::m_heurValue, SgBookNode::m_value, and SgDebug().

SgMove GoAutoBook::LookupMove ( const GoBoard brd  )  const

Helper function: calls FindBestChild() on the given board.

Definition at line 339 of file GoAutoBook.cpp.

References FindBestChild(), and GoAutoBookState::Synchronize().

void GoAutoBook::Merge ( const GoAutoBook other  ) 

Merge this book with given book.

Internal nodes in either book become internal nodes in merged book, counts are clobbered (max is taken). Leafs in both books are leafs in merged book, value is the set to be the average.

Todo:
Handle counts properly? Would need to know the original book the two books we are merging derived from.

Definition at line 147 of file GoAutoBook.cpp.

References SgBookNode::IsLeaf(), SgBookNode::m_count, m_data, SgBookNode::m_heurValue, and SgDebug().

std::vector< std::vector< SgMove > > GoAutoBook::ParseWorkList ( std::istream &  in  )  [static]

Parses a worklist from a stream.

Definition at line 387 of file GoAutoBook.cpp.

References SgDebug().

void GoAutoBook::Put ( const GoAutoBookState state,
const SgBookNode node 
)

Store the node in the given state.

Definition at line 126 of file GoAutoBook.cpp.

References GoAutoBookState::GetHashCode(), and m_data.

Referenced by TruncateByDepth().

void GoAutoBook::Save ( const std::string &  filename  )  const

Writes book to disk.

Definition at line 136 of file GoAutoBook.cpp.

References m_data.

Referenced by Flush().

void GoAutoBook::TruncateByDepth ( int  depth,
GoAutoBookState state,
GoAutoBook other 
) const

Copies a truncated version of the book into other.

Definition at line 206 of file GoAutoBook.cpp.

Referenced by TruncateByDepth().

void GoAutoBook::TruncateByDepth ( int  depth,
GoAutoBookState state,
GoAutoBook other,
std::set< SgHashCode > &  seen 
) const [private]

Member Data Documentation

Definition at line 154 of file GoAutoBook.h.

Referenced by Get(), GoAutoBook(), ImportHashValuePairs(), Merge(), Put(), and Save().

std::set<SgHashCode> GoAutoBook::m_disabled [private]

Definition at line 158 of file GoAutoBook.h.

Referenced by AddDisabledLines(), and FindBestChild().

std::string GoAutoBook::m_filename [private]

Definition at line 160 of file GoAutoBook.h.

Referenced by Flush().

Definition at line 156 of file GoAutoBook.h.

Referenced by FindBestChild().


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


Sun Mar 13 2011 Doxygen 1.7.1