Precomputed pattern specifying a virtual connection/ladder. More...
#include <VCPattern.hpp>
Classes | |
struct | GlobalData |
Public Member Functions | |
VCPattern (HexPoint end1, HexPoint end2, const bitset_t &must_have, const bitset_t ¬_oppt) | |
~VCPattern () | |
bitset_t | MustHave () const |
Returns cells that this player must have. | |
bitset_t | NotOpponent () const |
Returns cells that must not be opponent stones. | |
HexPoint | Endpoint (int i) const |
Returns the endpoints, i must be in [0, 1]. | |
bool | Matches (HexColor color, const StoneBoard &brd) const |
Returns true if this pattern matches the given board. | |
bool | ShiftPattern (HexDirection dir, const StoneBoard &brd) |
Shifts the pattern in direction dir, if possible. | |
Static Public Member Functions | |
static const VCPatternSet & | GetPatterns (int width, int height, HexColor color) |
Returns the set of patterns for the given boardsize; creates patterns if they currently do not exist. | |
Private Types | |
typedef std::map< std::pair < int, int >, VCPatternSet > | VCPatternSetMap |
Static Private Member Functions | |
static VCPatternSetMap & | GetConstructed (HexColor color) |
Returns the set of PatternSets already constructed. | |
static void | CreatePatterns (int width, int height) |
Creates the patterns for a given boardsize. | |
Private Attributes | |
bitset_t | m_must_have |
Cells that must be occupied. | |
bitset_t | m_not_oppt |
Cells that cannot be opponent stones. | |
HexPoint | m_end1 |
Endpoints connected by this VC. | |
HexPoint | m_end2 |
Precomputed pattern specifying a virtual connection/ladder.
Definition at line 23 of file VCPattern.hpp.
typedef std::map< std::pair<int, int>, VCPatternSet > VCPattern::VCPatternSetMap [private] |
Definition at line 71 of file VCPattern.hpp.
VCPattern::VCPattern | ( | HexPoint | end1, | |
HexPoint | end2, | |||
const bitset_t & | must_have, | |||
const bitset_t & | not_oppt | |||
) |
Definition at line 392 of file VCPattern.cpp.
VCPattern::~VCPattern | ( | ) |
Definition at line 401 of file VCPattern.cpp.
void VCPattern::CreatePatterns | ( | int | width, | |
int | height | |||
) | [static, private] |
Creates the patterns for a given boardsize.
Definition at line 205 of file VCPattern.cpp.
References BLACK, HexPointUtil::coordsToPoint(), DIR_EAST, GetConstructed(), HexAssert, LogFine(), benzene_bitset< _Nb >::set(), SOUTH, StoneBoard::StartNewGame(), and WHITE.
Referenced by GetPatterns().
HexPoint VCPattern::Endpoint | ( | int | i | ) | const [inline] |
Returns the endpoints, i must be in [0, 1].
Definition at line 94 of file VCPattern.hpp.
References HexAssert, m_end1, and m_end2.
Referenced by VCBuilder::AddPatternVCs(), and ShiftPattern().
VCPattern::VCPatternSetMap & VCPattern::GetConstructed | ( | HexColor | color | ) | [static, private] |
Returns the set of PatternSets already constructed.
Definition at line 162 of file VCPattern.cpp.
References VCPattern::GlobalData::constructed.
Referenced by CreatePatterns(), and GetPatterns().
const VCPatternSet & VCPattern::GetPatterns | ( | int | width, | |
int | height, | |||
HexColor | color | |||
) | [static] |
Returns the set of patterns for the given boardsize; creates patterns if they currently do not exist.
Return set of patterns will always be empty if width does not equal height.
Return an empty list for all non-square boards.
Definition at line 169 of file VCPattern.cpp.
References BLACK, CreatePatterns(), GetConstructed(), and WHITE.
Referenced by VCBuilder::AddPatternVCs().
bool VCPattern::Matches | ( | HexColor | color, | |
const StoneBoard & | brd | |||
) | const |
Returns true if this pattern matches the given board.
Definition at line 407 of file VCPattern.cpp.
References StoneBoard::Const(), ConstBoard::GetCells(), StoneBoard::GetColor(), BitsetUtil::IsSubsetOf(), m_must_have, and m_not_oppt.
Referenced by VCBuilder::AddPatternVCs().
bitset_t VCPattern::MustHave | ( | ) | const [inline] |
Returns cells that this player must have.
Definition at line 84 of file VCPattern.hpp.
References m_must_have.
Referenced by ShiftPattern().
bitset_t VCPattern::NotOpponent | ( | ) | const [inline] |
Returns cells that must not be opponent stones.
Definition at line 89 of file VCPattern.hpp.
References m_not_oppt.
Referenced by VCBuilder::AddPatternVCs(), and ShiftPattern().
bool VCPattern::ShiftPattern | ( | HexDirection | dir, | |
const StoneBoard & | brd | |||
) |
Shifts the pattern in direction dir, if possible.
Returns true on success, false if shifted pattern goes off board. ONLY USE THIS IF YOU KNOW WHAT YOU ARE DOING!
Definition at line 418 of file VCPattern.cpp.
References StoneBoard::Const(), Endpoint(), m_end1, m_end2, m_must_have, m_not_oppt, MustHave(), NotOpponent(), BoardUtils::PointInDir(), and BoardUtils::ShiftBitset().
HexPoint VCPattern::m_end1 [private] |
Endpoints connected by this VC.
Definition at line 67 of file VCPattern.hpp.
Referenced by Endpoint(), and ShiftPattern().
HexPoint VCPattern::m_end2 [private] |
Definition at line 67 of file VCPattern.hpp.
Referenced by Endpoint(), and ShiftPattern().
bitset_t VCPattern::m_must_have [private] |
Cells that must be occupied.
Definition at line 61 of file VCPattern.hpp.
Referenced by Matches(), MustHave(), and ShiftPattern().
bitset_t VCPattern::m_not_oppt [private] |
Cells that cannot be opponent stones.
Definition at line 64 of file VCPattern.hpp.
Referenced by Matches(), NotOpponent(), and ShiftPattern().