Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoBoardUtil.h File Reference


Detailed Description

GoBoard-related utility classes.

Definition in file GoBoardUtil.h.

#include "GoBoard.h"
#include "SgBoardColor.h"
#include "SgDebug.h"
#include "SgPoint.h"
#include "SgPointArray.h"
#include "SgStack.h"
#include "SgVector.h"

Go to the source code of this file.

Namespaces

namespace  GoBoardUtil
namespace  GoBoardWrite

Classes

class  GoRestoreKoRule
 Used to restore GoBoard::Rules()GetKoRule() to its current value in an exception-safe way. More...
class  GoRestoreToPlay
 Used to restore ToPlay to its current value in an exception-safe way. More...
class  GoBlockIterator
 Iterate over all blocks' anchors on the board. More...
class  GoRestoreSuicide
 Used to permit/forbid self-removal for certain periods of play. More...
class  GoRestoreRepetitionAndSuicide
 Used to alter state of repetition and self-removal for certain periods of play. More...
class  GoNeighborBlockIterator
 Iterate through the anchors of all the blocks adjacent to the given point. More...
class  GoAdjBlockIterator< BOARD >
 Iterate through the anchors of all the blocks adjacent to the given block. More...
class  GoNbIterator
class  GoBoardWrite::WriteMap
 Write a map of the board, showing marks for SgPointSet. More...

Functions

void GoBoardUtil::AddNeighborBlocksOfColor (const GoBoard &bd, SgPoint p, SgBlackWhite color, SgVector< SgPoint > &neighbors)
 Add anchors of neighbor blocks to list.
void GoBoardUtil::AddWall (GoBoard &bd, SgBlackWhite color, SgPoint start, int length, int direction)
 Add wall of stones in color to the board.
GoPointList GoBoardUtil::AdjacentStones (const GoBoard &bd, SgPoint point)
 Get list of stones adjacent to a block.
void GoBoardUtil::AdjacentBlocks (const GoBoard &bd, SgPoint p, int maxLib, SgVector< SgPoint > *blocks)
 SgVector version of GoBoard::AdjacentBlocks.
int GoBoardUtil::Approx2Libs (const GoBoard &board, SgPoint block, SgPoint p, SgBlackWhite color)
 Estimate second order liberties of point p for given block This is fast and approximate, may double count libs.
bool GoBoardUtil::AtLeastTwoSharedLibs (const GoBoard &bd, SgPoint block1, SgPoint block2)
 Return whether 'block1' and 'block2' have at least two shared liberties.
bool GoBoardUtil::BlockIsAdjacentTo (const GoBoard &bd, SgPoint block, const SgPointSet &walls)
void GoBoardUtil::BlocksAdjacentToPoints (const GoBoard &bd, const SgVector< SgPoint > &points, SgBlackWhite c, SgVector< SgPoint > *blocks)
void GoBoardUtil::BlocksAdjacentToPoints (const GoBoard &bd, const SgPointSet &points, SgBlackWhite c, SgVector< SgPoint > *anchors)
 List the anchors of all blocks of color 'c' adjacent to the region consisting of 'points'.
SgPointArray< int > GoBoardUtil::CfgDistance (const GoBoard &bd, SgPoint p, int maxDist=std::numeric_limits< int >::max())
 Compute the common fate graph distance from all points to a given point.
bool GoBoardUtil::ContainsAnchor (const SgPoint anchor[], const SgPoint p)
 Is p contained in anchor[] ? anchor[] must be terminated by END_POINT.
void GoBoardUtil::DiagonalsOfColor (const GoBoard &bd, SgPoint p, int c, SgVector< SgPoint > *diagonals)
 Get diagonal points with a color.
void GoBoardUtil::DumpBoard (const GoBoard &bd, std::ostream &out=SgDebug())
 Write board including move history to stream.
bool GoBoardUtil::EndOfGame (const GoBoard &bd)
 Return whether the game is finished.
void GoBoardUtil::ExpandToBlocks (const GoBoard &board, SgPointSet &pointSet)
 Add other stones of blocks to SgPointSet if one is in set.
template<class BOARD>
SgPoint GoBoardUtil::FindNeighbor (const BOARD &bd, SgPoint p, SgEmptyBlackWhite c)
 Find a neighboring point in color c.
bool GoBoardUtil::GenerateIfLegal (const GoBoard &bd, SgPoint move, SgVector< SgPoint > *moves)
 Include move in list if it is legal.
void GoBoardUtil::GetCoordString (SgMove move, std::string *s, int boardSize)
 Convert the given move to human-readable coordinates.
void GoBoardUtil::GetCoordString (const GoBoard &board, SgMove move, std::string *s)
 Convert the given move to human-readable coordinates.
SgRect GoBoardUtil::GetDirtyRegion (const GoBoard &bd, SgMove move, SgBlackWhite color, bool checklibs=false, bool premove=false)
 Which intersections were modified with the last move.
bool GoBoardUtil::HasAdjacentBlocks (const GoBoard &bd, SgPoint p, int maxLib)
 Return whether block has at least one adjacent opponent block with at most maxLib liberties.
bool GoBoardUtil::HasStonesOfBothColors (const GoBoard &bd, const SgVector< SgPoint > &stones)
template<class BOARD>
bool GoBoardUtil::IsCompletelySurrounded (const BOARD &bd, SgPoint p)
 Return if point is surrounded by one color and no adjacent block is in atari.
bool GoBoardUtil::IsHandicapPoint (SgGrid size, SgGrid col, SgGrid row)
template<class BOARD>
bool GoBoardUtil::IsNeighborOfSome (const BOARD &bd, SgPoint p, SgPoint anchors[], SgBlackWhite toPlay)
template<class BOARD>
bool GoBoardUtil::IsSimpleChain (const BOARD &bd, SgPoint block, SgPoint &other)
 Does block have two shared liberties with some other block? WARNING: for efficiency this checks only the first two liberties of the block.
bool GoBoardUtil::IsSimpleEyeOfBlock (const GoBoard &bd, SgPoint lib, SgPoint blockAnchor, const SgVector< SgPoint > &eyes)
 Is lib a simple eye of block? Eyes is a list of other eye points, that do not need to be occupied for lib to be an eye.
bool GoBoardUtil::IsSnapback (const GoBoard &bd, SgPoint p)
 Check if the move just played on p was a snapback.
SgPointSet GoBoardUtil::Lines (const GoBoard &bd, SgGrid from, SgGrid to)
 all points on lines [from.
bool GoBoardUtil::ManySecondaryLibs (const GoBoard &bd, SgPoint block)
bool GoBoardUtil::MoveNotLegalOrAtari (GoBoard &bd, SgPoint move)
 Either move is not legal, or the block at move is in atari after the move.
bool GoBoardUtil::MoveLegalAndNotAtari (GoBoard &bd, SgPoint move)
 Move is legal and the block at move is not in atari after the move.
SgSList< SgPoint, 4 > GoBoardUtil::NeighborsOfColor (const GoBoard &bd, SgPoint p, int c)
 Get adjacent points with a color.
void GoBoardUtil::NeighborsOfColor (const GoBoard &bd, SgPoint p, int c, SgVector< SgPoint > *neighbors)
 Get adjacent points with a color (SgVector version).
bool GoBoardUtil::PassWins (const GoBoard &bd, SgBlackWhite toPlay)
 Check if Tromp-Taylor rules and pass wins.
bool GoBoardUtil::PlayIfLegal (GoBoard &bd, SgPoint p, SgBlackWhite player)
 Play a move if legal.
bool GoBoardUtil::PlayIfLegal (GoBoard &bd, SgPoint p)
 Play a move for the current player if legal.
void GoBoardUtil::ReduceToAnchors (const GoBoard &bd, SgVector< SgPoint > *stones)
 Keep only the anchor of each block in the list.
void GoBoardUtil::ReduceToAnchors (const GoBoard &bd, const SgVector< SgPoint > &stones, SgSList< SgPoint, SG_MAXPOINT > &anchors)
 Keep only the anchor of each block in the list.
void GoBoardUtil::RegionCode (const GoBoard &bd, const SgVector< SgPoint > &region, SgHashCode *c)
 Compute the hash code for region of this board position.
bool GoBoardUtil::RemainingChineseHandicap (const GoBoard &bd)
 Returns true iff during the first N moves of a Chinese handicap game.
template<class BOARD>
bool GoBoardUtil::SelfAtari (const BOARD &bd, SgPoint p)
 Check if move would be self-atari.
template<class BOARD>
bool GoBoardUtil::SelfAtari (const BOARD &bd, SgPoint p, int &numStones)
 Same as above, but also compute number of stones put into selfatari.
template<class BOARD>
bool GoBoardUtil::SelfAtariForColor (const BOARD &bd, SgPoint p, SgBlackWhite toPlay)
 Check if move would be self-atari for given color.
void GoBoardUtil::SharedLiberties (const GoBoard &bd, SgPoint block1, SgPoint block2, SgVector< SgPoint > *sharedLibs)
 Return all points that are liberties of both 'block1' and 'block2'.
void GoBoardUtil::SharedLibertyBlocks (const GoBoard &bd, SgPoint anchor, int maxLib, SgVector< SgPoint > *blocks)
bool GoBoardUtil::ScorePosition (const GoBoard &bd, const SgPointSet &deadStones, float &score)
 Count score given the set of dead stones.
template<class BOARD>
SgEmptyBlackWhite GoBoardUtil::ScorePoint (const BOARD &bd, SgPoint p, bool noCheck)
 Helper function used in ScoreSimpleEndPosition.
template<class BOARD>
float GoBoardUtil::ScoreSimpleEndPosition (const BOARD &bd, float komi, const SgBWSet &safe, bool noCheck, SgPointArray< SgEmptyBlackWhite > *scoreBoard)
 Score position with given safe stones and only simple eyes.
float GoBoardUtil::ScoreSimpleEndPosition (const GoBoard &bd, float komi, bool noCheck=false)
 Score position with all stones safe and only simple eyes.
int GoBoardUtil::Stones (const GoBoard &bd, SgPoint p, SgPoint stones[])
 Fill stones in an array.
void GoBoardUtil::TestForChain (GoBoard &bd, SgPoint block, SgPoint block2, SgPoint lib, SgVector< SgPoint > *extended)
template<class BOARD>
float GoBoardUtil::TrompTaylorScore (const BOARD &bd, float komi, SgPointArray< SgEmptyBlackWhite > *scoreBoard=0)
 Compute the Tromp-Taylor-score for the current positions.
bool GoBoardUtil::TwoPasses (const GoBoard &bd)
 Check if the last two moves were two passes in a row, the first pass by the current color to play, the second by the opponent.
void GoBoardUtil::UndoAll (GoBoard &bd)
 Undo all moves or setup stones.
bool GoBoardUtil::ContainsAnchor (const SgPoint anchor[], const SgPoint p)
 Is p contained in anchor[] ? anchor[] must be terminated by END_POINT.
template<class BOARD>
SgPoint GoBoardUtil::FindNeighbor (const BOARD &bd, SgPoint p, SgEmptyBlackWhite c)
 Find a neighboring point in color c.
void GoBoardUtil::GetCoordString (const GoBoard &board, SgMove move, std::string *s)
 Convert the given move to human-readable coordinates.
template<class BOARD>
bool GoBoardUtil::IsCompletelySurrounded (const BOARD &bd, SgPoint p)
 Return if point is surrounded by one color and no adjacent block is in atari.
template<class BOARD>
bool GoBoardUtil::IsNeighborOfSome (const BOARD &bd, SgPoint p, SgPoint anchors[], SgBlackWhite toPlay)
template<class BOARD>
bool GoBoardUtil::IsSimpleChain (const BOARD &bd, SgPoint block, SgPoint &other)
 Does block have two shared liberties with some other block? WARNING: for efficiency this checks only the first two liberties of the block.
bool GoBoardUtil::PlayIfLegal (GoBoard &bd, SgPoint p)
 Play a move for the current player if legal.
template<class BOARD>
SgEmptyBlackWhite GoBoardUtil::ScorePoint (const BOARD &bd, SgPoint p, bool noCheck)
 Helper function used in ScoreSimpleEndPosition.
template<class BOARD>
float GoBoardUtil::ScoreSimpleEndPosition (const BOARD &bd, float komi, const SgBWSet &safe, bool noCheck, SgPointArray< SgEmptyBlackWhite > *scoreBoard)
 Score position with given safe stones and only simple eyes.
template<class BOARD>
bool GoBoardUtil::SelfAtari (const BOARD &bd, SgPoint p)
 Check if move would be self-atari.
template<class BOARD>
bool GoBoardUtil::SelfAtariForColor (const BOARD &bd, SgPoint p, SgBlackWhite toPlay)
 Check if move would be self-atari for given color.
template<class BOARD>
bool GoBoardUtil::SelfAtari (const BOARD &bd, SgPoint p, int &numStones)
 Same as above, but also compute number of stones put into selfatari.
template<class BOARD>
float GoBoardUtil::TrompTaylorScore (const BOARD &bd, float komi, SgPointArray< SgEmptyBlackWhite > *scoreBoard)
 Compute the Tromp-Taylor-score for the current positions.
template<class BOARD>
std::ostream & GoWriteBoard (std::ostream &out, const BOARD &bd)
std::ostream & operator<< (std::ostream &out, const GoBoard &bd)
std::ostream & operator<< (std::ostream &out, const GoBoardWrite::WriteMap &w)

Variables

static const int MAX_ADJACENT = (SG_MAX_SIZE + 1) * (SG_MAX_SIZE + 1) / 4


Function Documentation

template<class BOARD>
std::ostream& GoWriteBoard ( std::ostream &  out,
const BOARD &  bd 
)

Definition at line 818 of file GoBoardUtil.h.

References GoBoardUtil::IsHandicapPoint(), SgPointUtil::Pt(), SG_ASSERT, SG_BLACK, SG_EMPTY, SG_WHITE, and SgBW().

Referenced by operator<<().

std::ostream& operator<< ( std::ostream &  out,
const GoBoardWrite::WriteMap w 
)

Definition at line 964 of file GoBoardUtil.cpp.

References GoBoardWrite::WriteMap::Board(), GoBoardWrite::WriteMap::Points(), GoBoard::Size(), and SgPointSet::Write().

std::ostream& operator<< ( std::ostream &  out,
const GoBoard bd 
)

Definition at line 894 of file GoBoardUtil.h.

References GoWriteBoard().


Variable Documentation

const int MAX_ADJACENT = (SG_MAX_SIZE + 1) * (SG_MAX_SIZE + 1) / 4 [static]

Definition at line 1127 of file GoBoardUtil.h.

Referenced by GoAdjBlockIterator< BOARD >::GoAdjBlockIterator().


17 Jun 2010 Doxygen 1.4.7