Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

BoardUtils Namespace Reference

Utilities on Boards. More...

Functions

std::string GuiDumpOutsideConsiderSet (const StoneBoard &brd, const bitset_t &consider, const bitset_t &remove)
 Dumps all cells outside the consider set and the remove set in a format the gui expects.
Cells

HexPoint CoordsToPoint (const ConstBoard &brd, int x, int y)
 Returns HexPoint at the coordinates (x, y).
HexPoint PointInDir (const ConstBoard &brd, HexPoint p, HexDirection dir)
 Returns HexPoint in direction dir from the point p.
HexPoint Rotate (const ConstBoard &brd, HexPoint p)
 Rotates the given point 180' about the center of the board.
HexPoint Mirror (const ConstBoard &brd, HexPoint p)
 Mirrors the given point in the diagonal joining acute corners.
HexPoint CenterPoint (const ConstBoard &brd)
 Returns the center point on boards where both dimensions are odd (fails on all other boards).
HexPoint CenterPointRight (const ConstBoard &brd)
 These two methods return the two points nearest the center of the board.
HexPoint CenterPointLeft (const ConstBoard &brd)
HexPoint RandomEmptyCell (const StoneBoard &brd)
 Returns a random empty cell or INVALID_POINT if the board is full.
Bitsets

bitset_t PackBitset (const ConstBoard &brd, const bitset_t &in)
 Packs a bitset on this boardsize.
bitset_t UnpackBitset (const ConstBoard &brd, const bitset_t &in)
 Unpacks a bitset to the canonical representation.
bool ShiftBitset (const ConstBoard &brd, const bitset_t &bs, HexDirection dir, bitset_t &out)
 Shifts bitset in direction dir using PointInDir().
bitset_t Rotate (const ConstBoard &brd, const bitset_t &bs)
 Rotates the given bitset 180' about the center of the board.
bitset_t Mirror (const ConstBoard &brd, const bitset_t &bs)
 Mirrors the given bitset in the acute diagonal (requires that width equals height).
bool ConnectedOnBitset (const ConstBoard &brd, const bitset_t &carrier, HexPoint p1, HexPoint p2)
 Returns true if p1 is connected to p2 on the bitset; p1 and p2 are assumed to be inside the bitset.
bitset_t ReachableOnBitset (const ConstBoard &brd, const bitset_t &carrier, const bitset_t &stopset, HexPoint start)
 Returns a subset of carrier: the points that are reachable from start.
Decompositions

void InitializeDecompositions ()
 Must be called before any decomposition related function is called.
bool FindCombinatorialDecomposition (const HexBoard &brd, HexColor color, bitset_t &captured)
 Returns true if there is a combinatorial decomposition for color where the opposing color edges are VC-connected.
bool FindSplittingDecomposition (const HexBoard &brd, HexColor color, HexPoint &group)
 Returns true if there is a combinatorial decomposition for color that splits the board (i.e.

Detailed Description

Utilities on Boards.


Function Documentation

HexPoint BoardUtils::CenterPoint ( const ConstBoard brd  ) 

Returns the center point on boards where both dimensions are odd (fails on all other boards).

Definition at line 151 of file BoardUtils.cpp.

References CenterPointRight(), ConstBoard::Height(), HexAssert, and ConstBoard::Width().

Referenced by DfsSolverUtil::DistanceFromCenter().

HexPoint BoardUtils::CenterPointLeft ( const ConstBoard brd  ) 
See also:
centerPointRight().

Definition at line 167 of file BoardUtils.cpp.

References HexPointUtil::coordsToPoint(), ConstBoard::Height(), and ConstBoard::Width().

Referenced by DfsSolverUtil::DistanceFromCenter().

HexPoint BoardUtils::CenterPointRight ( const ConstBoard brd  ) 

These two methods return the two points nearest the center of the board.

On boards with one or more even dimensions, out of the center-most points the "top right" and "bottom left" points are returned as they relate to the main diagonals/visually. On boards with two odd dimensions, both of these methods return the same point as centerPoint().

Definition at line 157 of file BoardUtils.cpp.

References HexPointUtil::coordsToPoint(), ConstBoard::Height(), and ConstBoard::Width().

Referenced by CenterPoint(), and DfsSolverUtil::DistanceFromCenter().

bool BoardUtils::ConnectedOnBitset ( const ConstBoard brd,
const bitset_t carrier,
HexPoint  p1,
HexPoint  p2 
)

Returns true if p1 is connected to p2 on the bitset; p1 and p2 are assumed to be inside the bitset.

Referenced by DfsSolver::HandleProof().

HexPoint BoardUtils::CoordsToPoint ( const ConstBoard brd,
int  x,
int  y 
)

Returns HexPoint at the coordinates (x, y).

Note that edges have a single coordinate equal to -1 or width()/height(). That is, (-1, ?) is WEST, (?, -1) is NORTH, etc. Returns INVALID_POINT if (x, y) do not correspond to a valid point.

Definition at line 91 of file BoardUtils.cpp.

References HexPointUtil::coordsToPoint(), EAST, ConstBoard::Height(), INVALID_POINT, NORTH, SOUTH, WEST, and ConstBoard::Width().

Referenced by ConstBoard::ComputeNeighbours(), PatternMatcherData::Initialize(), and PointInDir().

bool BoardUtils::FindCombinatorialDecomposition ( const HexBoard brd,
HexColor  color,
bitset_t captured 
)

Returns true if there is a combinatorial decomposition for color where the opposing color edges are VC-connected.

The VC's carrier will be stored in captured. InitializeDecompositions() must be called once before this can be used.

Referenced by BenzeneHtpEngine::CmdFindCombDecomp(), and HexBoard::HandleVCDecomposition().

bool BoardUtils::FindSplittingDecomposition ( const HexBoard brd,
HexColor  color,
HexPoint group 
)

Returns true if there is a combinatorial decomposition for color that splits the board (i.e.

touches both edges of the opposite color). Group that splits the board is stored in group. InitializeDecompositions() must be called once before this can be used.

Definition at line 383 of file BoardUtils.cpp.

References benzene_bitset< _Nb >::any(), Groups::CaptainOf(), HexPointUtil::colorEdge1(), HexPointUtil::colorEdge2(), HexBoard::Const(), BitsetUtil::FirstSetBit(), ConstBoard::GetCells(), HexBoard::GetGroups(), and Groups::Nbs().

Referenced by BenzeneHtpEngine::CmdFindSplitDecomp(), and DfsSolver::SolveState().

std::string BoardUtils::GuiDumpOutsideConsiderSet ( const StoneBoard brd,
const bitset_t consider,
const bitset_t remove 
)

Dumps all cells outside the consider set and the remove set in a format the gui expects.

Referenced by VCCommands::CmdBuildIncremental(), VCCommands::CmdBuildStatic(), VCCommands::CmdGetMustPlay(), and DfsSolver::SolveInteriorState().

void BoardUtils::InitializeDecompositions (  ) 

Must be called before any decomposition related function is called.

Definition at line 293 of file BoardUtils.cpp.

Referenced by HexProgram::InitializeHexSystem().

bitset_t BoardUtils::Mirror ( const ConstBoard brd,
const bitset_t bs 
)

Mirrors the given bitset in the acute diagonal (requires that width equals height).

HexPoint BoardUtils::Mirror ( const ConstBoard brd,
HexPoint  p 
)
bitset_t BoardUtils::PackBitset ( const ConstBoard brd,
const bitset_t in 
)

Packs a bitset on this boardsize.

Output bitset has a bit for each cell on the board, starting at a1. That is, an 8x8 board can fit into exactly 64 bits. If in has a bit set at a1, then the packed bitset will have its 0th bit set; if in has a bit at a2, the second bit is set, etc, etc.

HexPoint BoardUtils::PointInDir ( const ConstBoard brd,
HexPoint  p,
HexDirection  dir 
)

Returns HexPoint in direction dir from the point p.

If p is an edge, returns p.

Definition at line 106 of file BoardUtils.cpp.

References CoordsToPoint(), HexPointUtil::DeltaX(), HexPointUtil::DeltaY(), HexAssert, HexPointUtil::isEdge(), HexPointUtil::isInteriorCell(), and HexPointUtil::pointToCoords().

Referenced by VCPattern::ShiftPattern().

HexPoint BoardUtils::RandomEmptyCell ( const StoneBoard brd  ) 

Returns a random empty cell or INVALID_POINT if the board is full.

Definition at line 178 of file BoardUtils.cpp.

References StoneBoard::Const(), benzene_bitset< _Nb >::count(), ConstBoard::GetCells(), StoneBoard::GetEmpty(), HexAssert, and INVALID_POINT.

Referenced by MoHexPlayer::Search(), and HandicapPlayer::Search().

bitset_t BoardUtils::ReachableOnBitset ( const ConstBoard brd,
const bitset_t carrier,
const bitset_t stopset,
HexPoint  start 
)

Returns a subset of carrier: the points that are reachable from start.

Flow will enter and leave cells in carrier, and enter but not leave cells in stopset.

Referenced by DfsSolver::HandleProof().

bitset_t BoardUtils::Rotate ( const ConstBoard brd,
const bitset_t bs 
)

Rotates the given bitset 180' about the center of the board.

HexPoint BoardUtils::Rotate ( const ConstBoard brd,
HexPoint  p 
)
bool BoardUtils::ShiftBitset ( const ConstBoard brd,
const bitset_t bs,
HexDirection  dir,
bitset_t out 
)

Shifts bitset in direction dir using PointInDir().

Returns true if each interior point is still an interior point.

Referenced by VCPattern::ShiftPattern().

bitset_t BoardUtils::UnpackBitset ( const ConstBoard brd,
const bitset_t in 
)

Unpacks a bitset to the canonical representation.

See also:
PackBitset()


6 Jan 2011 Doxygen 1.6.3