Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

VCPattern Class Reference

Precomputed pattern specifying a virtual connection/ladder. More...

#include <VCPattern.hpp>

List of all members.

Classes

struct  GlobalData

Public Member Functions

 VCPattern (HexPoint end1, HexPoint end2, const bitset_t &must_have, const bitset_t &not_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 VCPatternSetGetPatterns (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 VCPatternSetMapGetConstructed (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

Detailed Description

Precomputed pattern specifying a virtual connection/ladder.

Definition at line 23 of file VCPattern.hpp.


Member Typedef Documentation

typedef std::map< std::pair<int, int>, VCPatternSet > VCPattern::VCPatternSetMap [private]

Definition at line 71 of file VCPattern.hpp.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.

Bug:
The "vc-pattern-file" option is not checked here. This means that creating a VCPatternSet for board size (x,y), changing "vc-pattern-file", and then asking for a pattern set for (x,y) will not cause a re-build. No one will want to do this anyway (right?), so it doesn't matter. If you really want to do this, add the filename as part of the key for VCPatternSetMap.

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().


Member Data Documentation

Endpoints connected by this VC.

Definition at line 67 of file VCPattern.hpp.

Referenced by Endpoint(), and ShiftPattern().

Definition at line 67 of file VCPattern.hpp.

Referenced by Endpoint(), and ShiftPattern().

Cells that must be occupied.

Definition at line 61 of file VCPattern.hpp.

Referenced by Matches(), MustHave(), and ShiftPattern().

Cells that cannot be opponent stones.

Definition at line 64 of file VCPattern.hpp.

Referenced by Matches(), NotOpponent(), and ShiftPattern().


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


6 Jan 2011 Doxygen 1.6.3