Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

HexBoard Class Reference

Board that updates groups, pattern states, and vcs. More...

#include <HexBoard.hpp>

List of all members.

Classes

struct  History
 Stores state of the board. More...

Public Member Functions

 HexBoard (int width, int height, const ICEngine &ice, VCBuilderParam &param)
 Creates a rectangular board.
 HexBoard (const HexBoard &other)
 Copy constructor.
 ~HexBoard ()
 Destructor.
void ComputeAll (HexColor color)
 Clears history.
void PlayMove (HexColor color, HexPoint cell)
 Stores old state on stack, plays move to board, updates ics/vcs.
void PlayStones (HexColor color, const bitset_t &played, HexColor color_to_move)
 Stores old state on stack, plays set of stones, updates ics/vcs.
void UndoMove ()
 Reverts to last state stored on the stack, restoring all state info.
StoneBoardGetPosition ()
const StoneBoardGetPosition () const
const ConstBoardConst () const
bitset_t GetDead () const
 Returns the set of dead cells on the board.
const InferiorCellsGetInferiorCells () const
 Returns the set of inferior cell.
const ICEngineICE () const
 Returns the Inferior Cell Engine the board is using.
const GroupsGetGroups () const
GroupsGetGroups ()
const PatternStateGetPatternState () const
PatternStateGetPatternState ()
const VCSetCons (HexColor color) const
 Returns the connection set for color.
VCSetCons (HexColor color)
 Returns the connection set for color.
VCBuilderBuilder ()
 Returns the connection builder for this board.
const VCBuilderBuilder () const
 Returns the connection builder for this board.
int Width () const
int Height () const
std::string Write () const
std::string Write (const bitset_t &bs) const
Parameters

bool UseVCs () const
 Whether VCs are computed or not.
void SetUseVCs (bool enable)
 See UseVCs().
bool UseICE () const
 Whether ICE is used.
void SetUseICE (bool enable)
 See UseICE().
bool UseDecompositions () const
 Whether decompositions are found and filled-in.
void SetUseDecompositions (bool enable)
 See UseDecompositions().
bool BackupIceInfo () const
 Whether ICE info is backed-up in UndoMove().
void SetBackupIceInfo (bool enable)
 See BackupIceInfo().

Private Member Functions

void operator= (const HexBoard &other)
 No assignments allowed! Use the copy constructor if you must make a copy, but you shouldn't be copying boards around very often.
void Initialize ()
void ComputeInferiorCells (HexColor color_to_move)
void BuildVCs ()
void BuildVCs (const Groups &oldGroups, bitset_t added[BLACK_AND_WHITE], bool use_changelog)
void MarkChangeLog ()
void RevertVCs ()
void HandleVCDecomposition (HexColor color_to_move, bool use_changelog)
 In non-terminal states, checks for combinatorial decomposition with a vc using BoardUtils::FindCombinatorialDecomposition().
void AddStones (HexColor color, const bitset_t &played, HexColor color_to_move, bool use_changelog)
 Adds stones for color to board with color_to_move about to play next; added stones must be a subset of the empty cells.
void ClearHistory ()
void PushHistory (HexColor color, HexPoint cell)
void PopHistory ()
 Restores the old board position, backs up ice info, and reverts virtual connections.

Private Attributes

Member variables.

Warning:
If you change anything here, be sure to update the copy constructor!!
StoneBoard m_brd
const ICEnginem_ice
 ICEngine used to compute inferior cells.
Groups m_groups
PatternState m_patterns
VCBuilder m_builder
 Builder used to compute virtual connections.
boost::scoped_ptr< VCSetm_cons [BLACK_AND_WHITE]
 Connection sets for black and white.
ChangeLog< VCm_log [BLACK_AND_WHITE]
 The vc changelogs for both black and white.
std::vector< Historym_history
 History stack.
InferiorCells m_inf
 The set of inferior cells for the current boardstate.
bool m_use_vcs
 See UseVCs().
bool m_use_ice
 See UseICE().
bool m_use_decompositions
 See UseDecompositions().
bool m_backup_ice_info
 See BackupIceInfo().

Detailed Description

Board that updates groups, pattern states, and vcs.

Todo:
Document me!

Definition at line 27 of file HexBoard.hpp.


Constructor & Destructor Documentation

HexBoard::HexBoard ( int  width,
int  height,
const ICEngine ice,
VCBuilderParam param 
)

Creates a rectangular board.

Definition at line 18 of file HexBoard.cpp.

References Initialize().

HexBoard::HexBoard ( const HexBoard other  ) 

Copy constructor.

Warning:
This is not very maintainable! How to make this copy-constructable nicely, even though it has a scoped_ptr?

Definition at line 35 of file HexBoard.cpp.

References PatternState::CopyState(), GetPatternState(), m_cons, m_log, and m_patterns.

HexBoard::~HexBoard (  ) 

Destructor.

Definition at line 64 of file HexBoard.cpp.


Member Function Documentation

void HexBoard::AddStones ( HexColor  color,
const bitset_t played,
HexColor  color_to_move,
bool  use_changelog 
) [private]

Adds stones for color to board with color_to_move about to play next; added stones must be a subset of the empty cells.

Does not affect the hash of this state. State is not pushed onto stack, so a call to UndoMove() will undo these changes along with the last changes that changed the stack.

Definition at line 246 of file HexBoard.cpp.

References StoneBoard::AddColor(), BLACK, BLACK_AND_WHITE, GroupBuilder::Build(), BuildVCs(), ComputeInferiorCells(), Get(), StoneBoard::GetColor(), GetPosition(), HexAssert, BitsetUtil::IsSubsetOf(), LogFine(), m_brd, m_groups, m_patterns, m_use_vcs, HexPointUtil::ToString(), PatternState::Update(), and WHITE.

Referenced by HandleVCDecomposition().

bool HexBoard::BackupIceInfo (  )  const [inline]

Whether ICE info is backed-up in UndoMove().

Definition at line 348 of file HexBoard.hpp.

References m_backup_ice_info.

Referenced by HexEnvironmentCommands::ParamBoard().

const VCBuilder & HexBoard::Builder (  )  const [inline]

Returns the connection builder for this board.

Definition at line 313 of file HexBoard.hpp.

References m_builder.

VCBuilder & HexBoard::Builder (  )  [inline]
void HexBoard::BuildVCs ( const Groups oldGroups,
bitset_t  added[BLACK_AND_WHITE],
bool  use_changelog 
) [private]

Definition at line 86 of file HexBoard.cpp.

References BLACK, VCBuilder::Build(), HexAssert, m_builder, m_cons, m_groups, m_log, m_patterns, and WHITE.

void HexBoard::BuildVCs (  )  [private]

Definition at line 80 of file HexBoard.cpp.

References VCBuilder::Build(), m_builder, m_cons, m_groups, and m_patterns.

Referenced by AddStones(), ComputeAll(), PlayMove(), and PlayStones().

void HexBoard::ClearHistory (  )  [private]

Definition at line 288 of file HexBoard.cpp.

References m_history.

Referenced by Initialize().

void HexBoard::ComputeAll ( HexColor  color  ) 
void HexBoard::ComputeInferiorCells ( HexColor  color_to_move  )  [private]
VCSet & HexBoard::Cons ( HexColor  color  )  [inline]

Returns the connection set for color.

Definition at line 303 of file HexBoard.hpp.

References m_cons.

const VCSet & HexBoard::Cons ( HexColor  color  )  const [inline]
const ConstBoard & HexBoard::Const (  )  const [inline]
bitset_t HexBoard::GetDead (  )  const [inline]

Returns the set of dead cells on the board.

This is the union of all cells found dead previously during the history of moves since the last ComputeAll() call.

Definition at line 263 of file HexBoard.hpp.

References InferiorCells::Dead(), and m_inf.

Referenced by DfsSolver::HandleProof(), and DfsSolver::SolveDecomposition().

Groups & HexBoard::GetGroups (  )  [inline]

Definition at line 283 of file HexBoard.hpp.

References m_groups.

const Groups & HexBoard::GetGroups (  )  const [inline]
const InferiorCells & HexBoard::GetInferiorCells (  )  const [inline]
PatternState & HexBoard::GetPatternState (  )  [inline]

Definition at line 293 of file HexBoard.hpp.

References m_patterns.

const PatternState & HexBoard::GetPatternState (  )  const [inline]
const StoneBoard & HexBoard::GetPosition (  )  const [inline]

Definition at line 253 of file HexBoard.hpp.

References m_brd.

StoneBoard & HexBoard::GetPosition (  )  [inline]
void HexBoard::HandleVCDecomposition ( HexColor  color_to_move,
bool  use_changelog 
) [private]

In non-terminal states, checks for combinatorial decomposition with a vc using BoardUtils::FindCombinatorialDecomposition().

Plays the carrier using AddStones(). Loops until no more decompositions are found.

Todo:
Check for a vc win/loss here instead of just solid chains.

Definition at line 114 of file HexBoard.cpp.

References InferiorCells::AddCaptured(), AddStones(), BoardUtils::FindCombinatorialDecomposition(), Groups::IsGameOver(), LogFine(), m_brd, m_groups, m_inf, m_use_decompositions, and StoneBoard::Write().

Referenced by ComputeAll(), PlayMove(), and PlayStones().

int HexBoard::Height (  )  const [inline]
const ICEngine & HexBoard::ICE (  )  const [inline]

Returns the Inferior Cell Engine the board is using.

Definition at line 273 of file HexBoard.hpp.

References m_ice.

Referenced by DfsCommands::CmdSolverFindWinning(), DfsCommands::CmdSolveState(), DfsSolver::HandleProof(), VulPreCheck::KillLastMove(), DfsSolver::Solve(), and HexUctState::StartSearch().

void HexBoard::Initialize (  )  [private]

Definition at line 56 of file HexBoard.cpp.

References GroupBuilder::Build(), ClearHistory(), Const(), m_brd, m_cons, and m_groups.

Referenced by HexBoard().

void HexBoard::MarkChangeLog (  )  [private]

Definition at line 98 of file HexBoard.cpp.

References BLACK, m_log, ChangeLog< T >::push(), and WHITE.

Referenced by PlayMove(), and PlayStones().

void HexBoard::operator= ( const HexBoard other  )  [private]

No assignments allowed! Use the copy constructor if you must make a copy, but you shouldn't be copying boards around very often.

void HexBoard::PlayMove ( HexColor  color,
HexPoint  cell 
)
void HexBoard::PlayStones ( HexColor  color,
const bitset_t played,
HexColor  color_to_move 
)

Stores old state on stack, plays set of stones, updates ics/vcs.

HASH IS NOT MODIFIED! No ice info will be backed up, but this set of moves can be reverted with a single call to UndoMove().

Definition at line 206 of file HexBoard.cpp.

References StoneBoard::AddColor(), BLACK, BLACK_AND_WHITE, GroupBuilder::Build(), BuildVCs(), VCBuilder::ClearStatistics(), ComputeInferiorCells(), Get(), StoneBoard::GetColor(), GetPosition(), HandleVCDecomposition(), HexAssert, INVALID_POINT, BitsetUtil::IsSubsetOf(), LogFine(), m_brd, m_builder, m_groups, m_patterns, m_use_vcs, MarkChangeLog(), PushHistory(), HexPointUtil::ToString(), PatternState::Update(), and WHITE.

Referenced by DfsSolver::SolveDecomposition().

void HexBoard::PopHistory (  )  [private]

Restores the old board position, backs up ice info, and reverts virtual connections.

Definition at line 300 of file HexBoard.cpp.

References InferiorCells::Captured(), InferiorCells::Dead(), StoneBoard::GetEmpty(), HexAssert, INVALID_POINT, m_backup_ice_info, m_brd, m_groups, m_history, m_inf, RevertVCs(), and StoneBoard::SetPosition().

Referenced by UndoMove().

void HexBoard::PushHistory ( HexColor  color,
HexPoint  cell 
) [private]

Definition at line 293 of file HexBoard.cpp.

References m_brd, m_groups, m_history, and m_inf.

Referenced by PlayMove(), and PlayStones().

void HexBoard::RevertVCs (  )  [private]

Definition at line 104 of file HexBoard.cpp.

References m_cons, and m_log.

Referenced by PopHistory().

void HexBoard::SetBackupIceInfo ( bool  enable  )  [inline]

See BackupIceInfo().

Definition at line 353 of file HexBoard.hpp.

References m_backup_ice_info.

Referenced by HexEnvironmentCommands::ParamBoard().

void HexBoard::SetUseDecompositions ( bool  enable  )  [inline]
void HexBoard::SetUseICE ( bool  enable  )  [inline]
void HexBoard::SetUseVCs ( bool  enable  )  [inline]

See UseVCs().

Definition at line 323 of file HexBoard.hpp.

References m_use_vcs.

Referenced by HexEnvironmentCommands::ParamBoard().

void HexBoard::UndoMove (  ) 

Reverts to last state stored on the stack, restoring all state info.

If the option is on, also backs up inferior cell info.

Definition at line 275 of file HexBoard.cpp.

References Get(), LogFine(), m_patterns, PopHistory(), and PatternState::Update().

Referenced by BenzeneHtpEngine::CmdEvalResistDelta(), MoHexPlayer::PerformPreSearch(), DfsSolver::SolveDecomposition(), WolveSearch::UndoMove(), and DfsSolver::UndoMove().

bool HexBoard::UseDecompositions (  )  const [inline]

Whether decompositions are found and filled-in.

Definition at line 338 of file HexBoard.hpp.

References m_use_decompositions.

Referenced by BenzeneHtpEngine::CmdFindCombDecomp(), and HexEnvironmentCommands::ParamBoard().

bool HexBoard::UseICE (  )  const [inline]

Whether ICE is used.

Definition at line 328 of file HexBoard.hpp.

References m_use_ice.

Referenced by BookBuilder< PLAYER >::GenerateMoves(), BenzenePlayer::InitSearch(), and HexEnvironmentCommands::ParamBoard().

bool HexBoard::UseVCs (  )  const [inline]

Whether VCs are computed or not.

Definition at line 318 of file HexBoard.hpp.

References m_use_vcs.

Referenced by HexEnvironmentCommands::ParamBoard().

int HexBoard::Width (  )  const [inline]
std::string HexBoard::Write ( const bitset_t bs  )  const [inline]

Definition at line 373 of file HexBoard.hpp.

References m_brd, and StoneBoard::Write().

std::string HexBoard::Write (  )  const [inline]

Member Data Documentation

See BackupIceInfo().

Definition at line 212 of file HexBoard.hpp.

Referenced by BackupIceInfo(), PopHistory(), and SetBackupIceInfo().

Builder used to compute virtual connections.

Definition at line 188 of file HexBoard.hpp.

Referenced by Builder(), BuildVCs(), ComputeAll(), PlayMove(), and PlayStones().

boost::scoped_ptr<VCSet> HexBoard::m_cons[BLACK_AND_WHITE] [private]

Connection sets for black and white.

Definition at line 191 of file HexBoard.hpp.

Referenced by BuildVCs(), Cons(), HexBoard(), Initialize(), and RevertVCs().

std::vector<History> HexBoard::m_history [private]

History stack.

Definition at line 197 of file HexBoard.hpp.

Referenced by ClearHistory(), PopHistory(), and PushHistory().

const ICEngine* HexBoard::m_ice [private]

ICEngine used to compute inferior cells.

Definition at line 181 of file HexBoard.hpp.

Referenced by ComputeInferiorCells(), and ICE().

The set of inferior cells for the current boardstate.

Definition at line 200 of file HexBoard.hpp.

Referenced by ComputeAll(), ComputeInferiorCells(), GetDead(), GetInferiorCells(), HandleVCDecomposition(), PopHistory(), and PushHistory().

The vc changelogs for both black and white.

Definition at line 194 of file HexBoard.hpp.

Referenced by BuildVCs(), HexBoard(), MarkChangeLog(), and RevertVCs().

bool HexBoard::m_use_ice [private]

See UseICE().

Definition at line 206 of file HexBoard.hpp.

Referenced by ComputeInferiorCells(), SetUseICE(), and UseICE().

bool HexBoard::m_use_vcs [private]

See UseVCs().

Definition at line 203 of file HexBoard.hpp.

Referenced by AddStones(), ComputeAll(), PlayMove(), PlayStones(), SetUseVCs(), and UseVCs().


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


6 Jan 2011 Doxygen 1.6.3