Stores the connections for a board and color. More...
#include <VCSet.hpp>
Public Member Functions | |
VCSet (const ConstBoard &brd, HexColor color) | |
Creates a VCSet class on the given board size for color. | |
VCSet (const VCSet &other) | |
Copy constructor. | |
virtual | ~VCSet () |
Destructor. | |
HexColor | Color () const |
Returns the color of this set of connections. | |
const ConstBoard & | Board () const |
Returns the board the set is defined on. | |
int | SoftLimit (VC::Type) const |
Returns soft limit for the given type of VC. | |
const VCList & | GetList (VC::Type type, HexPoint x, HexPoint y) const |
Returns the VCList between (x, y). | |
VCList & | GetList (VC::Type type, HexPoint x, HexPoint y) |
Returns the VCList between (x, y). | |
bool | Exists (HexPoint x, HexPoint y, VC::Type type) const |
Determines if there is at least one valid connection between the given pair of cells for the color and VC type, x and y must both be the color of this connection set. | |
bool | SmallestVC (HexPoint x, HexPoint y, VC::Type type, VC &out) const |
Copies the smallest connection between x and y of type into out, returns true if successful. | |
void | VCs (HexPoint x, HexPoint y, VC::Type type, std::vector< VC > &out) const |
Stores the valid connections between x and y for color in out (which is cleared beforehand). | |
Modifying methods | |
void | SetSoftLimit (VC::Type, int limit) |
See SoftLimit(). | |
void | Clear () |
Clears the connections. | |
VCList::AddResult | Add (const VC &vc, ChangeLog< VC > *log) |
Attempts to add the given vc to the list between (vc.x(), vc.y()). | |
void | Revert (ChangeLog< VC > &log) |
Uses the given changelog to revert connections to state at last marker in the changelog. | |
Operators | |
void | operator= (const VCSet &other) |
Assignment operator. | |
bool | operator== (const VCSet &other) const |
Returns true if other is isomorphic to us. | |
bool | operator!= (const VCSet &other) const |
Returns true if other is not isomorphic to us. | |
Private Member Functions | |
void | AllocateAndCopyLists (const VCSet &other) |
Allocates space for, and copies lists from, the VCLists in other. | |
void | FreeLists () |
Frees all allocated VCLists. | |
Private Attributes | |
const ConstBoard * | m_brd |
HexColor | m_color |
VCList * | m_vc [VC::NUM_TYPES][BITSETSIZE][BITSETSIZE] |
The lists of vcs. |
Stores the connections for a board and color.
Definition at line 24 of file VCSet.hpp.
VCSet::VCSet | ( | const ConstBoard & | brd, | |
HexColor | color | |||
) |
VCSet::VCSet | ( | const VCSet & | other | ) |
VCSet::~VCSet | ( | ) | [virtual] |
VCList::AddResult VCSet::Add | ( | const VC & | vc, | |
ChangeLog< VC > * | log | |||
) | [inline] |
Attempts to add the given vc to the list between (vc.x(), vc.y()).
Returns result of the add operation. This method is just a wrapper for GetList(vc.type(), vc.x(), vc.y())->add(vc).
Definition at line 156 of file VCSet.hpp.
References VCList::add(), m_vc, VC::type(), VC::x(), and VC::y().
Referenced by VCBuilder::AddBaseVCs(), VCBuilder::AddNewFull(), and VCBuilder::AddPatternVCs().
void VCSet::AllocateAndCopyLists | ( | const VCSet & | other | ) | [private] |
Allocates space for, and copies lists from, the VCLists in other.
Definition at line 56 of file VCSet.cpp.
References ConstBoard::EdgesAndInterior(), VC::FULL, m_brd, m_vc, and VC::SEMI.
Referenced by operator=(), and VCSet().
const ConstBoard & VCSet::Board | ( | ) | const [inline] |
Returns the board the set is defined on.
Definition at line 138 of file VCSet.hpp.
References m_brd.
Referenced by VCSetUtil::EqualOnGroups().
void VCSet::Clear | ( | ) |
Clears the connections.
Definition at line 124 of file VCSet.cpp.
References VCList::clear(), ConstBoard::EdgesAndInterior(), m_brd, m_vc, and VC::NUM_TYPES.
Referenced by VCBuilder::Build().
HexColor VCSet::Color | ( | ) | const [inline] |
Returns the color of this set of connections.
Definition at line 133 of file VCSet.hpp.
References m_color.
Referenced by VCBuilder::Build(), VCSetUtil::ComputeStatistics(), VCSetUtil::ConnectedTo(), and VCSetUtil::EqualOnGroups().
Determines if there is at least one valid connection between the given pair of cells for the color and VC type, x and y must both be the color of this connection set.
Definition at line 91 of file VCSet.cpp.
References VCList::empty(), and m_vc.
Referenced by VCSetUtil::ConnectedTo(), VCBuilder::DoSearch(), VCUtils::GetMustplay(), DfsSolver::OrderMoves(), and SmallestVC().
void VCSet::FreeLists | ( | ) | [private] |
Frees all allocated VCLists.
Definition at line 78 of file VCSet.cpp.
References ConstBoard::EdgesAndInterior(), m_brd, m_vc, and VC::NUM_TYPES.
Referenced by operator=(), and ~VCSet().
Returns the VCList between (x, y).
Definition at line 144 of file VCSet.hpp.
References m_vc.
Referenced by VCBuilder::AddNewFull(), VCBuilder::AddNewSemi(), VCBuilder::andClosure(), VCCommands::CmdGetVCsBetween(), VCCommands::CmdVCIntersection(), VCCommands::CmdVCUnion(), VCSetUtil::ComputeStatistics(), VCSetUtil::EqualOnGroups(), VCUtils::GetMustplay(), ProofUtil::InitialProofForOpponent(), VCBuilder::MergeAndShrink(), VCBuilder::ProcessFulls(), VCBuilder::ProcessSemis(), and VCBuilder::RemoveAllContaining().
bool VCSet::operator!= | ( | const VCSet & | other | ) | const |
Returns true if other is not isomorphic to us.
Definition at line 185 of file VCSet.cpp.
References operator==().
void VCSet::operator= | ( | const VCSet & | other | ) |
Assignment operator.
Definition at line 48 of file VCSet.cpp.
References AllocateAndCopyLists(), FreeLists(), m_brd, and m_color.
bool VCSet::operator== | ( | const VCSet & | other | ) | const |
Returns true if other is isomorphic to us.
Definition at line 167 of file VCSet.cpp.
References ConstBoard::EdgesAndInterior(), VC::FULL, m_brd, m_vc, and VC::SEMI.
Referenced by operator!=().
Uses the given changelog to revert connections to state at last marker in the changelog.
Log will will have all entries and last marker removed.
Definition at line 135 of file VCSet.cpp.
References ChangeLog< T >::empty(), VCList::end(), VCList::find(), HexAssert, m_vc, ChangeLog< T >::pop(), VCList::remove(), VCList::simple_add(), ChangeLog< T >::topAction(), and ChangeLog< T >::topData().
void VCSet::SetSoftLimit | ( | VC::Type | type, | |
int | limit | |||
) |
See SoftLimit().
Definition at line 116 of file VCSet.cpp.
References ConstBoard::EdgesAndInterior(), m_brd, and m_vc.
Referenced by HexEnvironmentCommands::ParamVC().
Copies the smallest connection between x and y of type into out, returns true if successful.
Returns false if no connection exists between x and y.
Definition at line 96 of file VCSet.cpp.
References VCList::begin(), Exists(), and m_vc.
Referenced by TwoDistance::IsAdjacent(), EndgameUtils::IsLostGame(), and EndgameUtils::IsWonGame().
int VCSet::SoftLimit | ( | VC::Type | type | ) | const [inline] |
Returns soft limit for the given type of VC.
This affects VCBuilder's performance!
Definition at line 161 of file VCSet.hpp.
References HexPointUtil::colorEdge1(), HexPointUtil::colorEdge2(), m_color, m_vc, and VCList::softlimit().
Referenced by HexEnvironmentCommands::ParamVC().
Stores the valid connections between x and y for color in out (which is cleared beforehand).
Definition at line 105 of file VCSet.cpp.
References VCList::begin(), VCList::end(), and m_vc.
Referenced by VCCommands::CmdGetVCsBetween().
const ConstBoard* VCSet::m_brd [private] |
Definition at line 122 of file VCSet.hpp.
Referenced by AllocateAndCopyLists(), Board(), Clear(), FreeLists(), operator=(), operator==(), SetSoftLimit(), and VCSet().
HexColor VCSet::m_color [private] |
Definition at line 125 of file VCSet.hpp.
Referenced by Color(), operator=(), and SoftLimit().
VCList* VCSet::m_vc[VC::NUM_TYPES][BITSETSIZE][BITSETSIZE] [private] |
The lists of vcs.
Definition at line 130 of file VCSet.hpp.
Referenced by Add(), AllocateAndCopyLists(), Clear(), Exists(), FreeLists(), GetList(), operator==(), Revert(), SetSoftLimit(), SmallestVC(), SoftLimit(), VCs(), and VCSet().