Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

GoLadder Class Reference

This class contains all the ladder-specific stuff. More...

#include <GoLadder.h>

List of all members.

Public Member Functions

 GoLadder ()
int Ladder (const GoBoard &bd, SgPoint prey, SgBlackWhite toPlay, SgVector< SgPoint > *sequence, bool twoLibIsEscape=false)
 Main ladder routine.

Private Member Functions

bool CheckMoveOverflow () const
void InitMaxMoveNumber ()
bool PointIsAdjToPrey (SgPoint p)
bool BlockIsAdjToPrey (SgPoint p, int numAdj)
void MarkStonesAsPrey (SgPoint p, SgVector< SgPoint > *stones=0)
 Marks all stones in the block p as part of the prey.
void FilterAdjacent (GoPointList &adjBlocks)
 Filter out captured blocks, blocks not in atari, and blocks not adjacent to the prey.
int PlayHunterMove (int depth, SgPoint move, SgPoint lib1, SgPoint lib2, const GoPointList &adjBlk, SgVector< SgPoint > *sequence)
 Play hunter move and update all the relevant information.
int PlayPreyMove (int depth, SgPoint move, SgPoint lib1, const GoPointList &adjBlk, SgVector< SgPoint > *sequence)
 Play prey move and update all the relevant information.
bool IsSnapback (SgPoint prey)
 Check whether the block at 'prey' is caught in a snapback.
int PreyLadder (int depth, SgPoint lib1, const GoPointList &adjBlk, SgVector< SgPoint > *sequence)
int HunterLadder (int depth, SgPoint lib1, const GoPointList &adjBlk, SgVector< SgPoint > *sequence)
int HunterLadder (int depth, SgPoint lib1, SgPoint lib2, const GoPointList &adjBlk, SgVector< SgPoint > *sequence)
void ReduceToBlocks (GoPointList &stones)

Private Attributes

int m_maxMoveNumber
 Maximum move number before ladder should be aborted.
GoBoardm_bd
SgPointSet m_partOfPrey
SgBlackWhite m_preyColor
SgBlackWhite m_hunterColor

Static Private Attributes

static const int MAX_LADDER_MOVES = 200
 Maximum number of moves in ladder.

Detailed Description

This class contains all the ladder-specific stuff.

Definition at line 40 of file GoLadder.h.


Constructor & Destructor Documentation

GoLadder::GoLadder (  ) 

Definition at line 32 of file GoLadder.cpp.


Member Function Documentation

bool GoLadder::BlockIsAdjToPrey ( SgPoint  p,
int  numAdj 
) [private]

Definition at line 96 of file GoLadder.cpp.

References GoBoard::IsColor(), m_bd, m_hunterColor, PointIsAdjToPrey(), and SG_ASSERT.

Referenced by FilterAdjacent(), Ladder(), and PreyLadder().

bool GoLadder::CheckMoveOverflow (  )  const [private]

Definition at line 36 of file GoLadder.cpp.

References m_bd, m_maxMoveNumber, and GoBoard::MoveNumber().

Referenced by HunterLadder(), Ladder(), and PreyLadder().

void GoLadder::FilterAdjacent ( GoPointList adjBlocks  )  [private]

Filter out captured blocks, blocks not in atari, and blocks not adjacent to the prey.

The latter are found by checking whether blocks adjacent to the block in question are the prey or not. Does not return the correct blocks if the prey has more than three liberties, but in that case, the prey has escaped anyway.

Definition at line 73 of file GoLadder.cpp.

References BlockIsAdjToPrey(), GoBoard::InAtari(), GoBoard::IsColor(), SgArrayList< SgPoint, SG_MAX_ONBOARD+1 >::Iterator, m_bd, m_hunterColor, SgArrayList< T, SIZE >::PushBack(), and ReduceToBlocks().

Referenced by Ladder(), and PlayPreyMove().

int GoLadder::HunterLadder ( int  depth,
SgPoint  lib1,
SgPoint  lib2,
const GoPointList adjBlk,
SgVector< SgPoint > *  sequence 
) [private]
int GoLadder::HunterLadder ( int  depth,
SgPoint  lib1,
const GoPointList adjBlk,
SgVector< SgPoint > *  sequence 
) [private]

Definition at line 295 of file GoLadder.cpp.

References CheckMoveOverflow(), SgVector< T >::SetTo(), and SG_UNUSED().

Referenced by Ladder(), and PlayPreyMove().

void GoLadder::InitMaxMoveNumber (  )  [private]

Definition at line 41 of file GoLadder.cpp.

References GO_MAX_NUM_MOVES, m_bd, m_maxMoveNumber, MAX_LADDER_MOVES, and GoBoard::MoveNumber().

Referenced by Ladder().

bool GoLadder::IsSnapback ( SgPoint  prey  )  [private]

Check whether the block at 'prey' is caught in a snapback.

Snapback means that it can be captured, but it's only a single stone, and the prey can capture right back.

Definition at line 519 of file GoLadder.cpp.

References GoBoard::GetStone(), GoBoard::InAtari(), GoBoard::IsSingleStone(), m_bd, GoBoardUtil::PlayIfLegal(), SgOppBW(), and GoBoard::Undo().

Referenced by Ladder().

int GoLadder::Ladder ( const GoBoard bd,
SgPoint  prey,
SgBlackWhite  toPlay,
SgVector< SgPoint > *  sequence,
bool  twoLibIsEscape = false 
)
void GoLadder::MarkStonesAsPrey ( SgPoint  p,
SgVector< SgPoint > *  stones = 0 
) [private]

Marks all stones in the block p as part of the prey.

If 'stones' is not 0, then append the stones to the existing list.

Definition at line 52 of file GoLadder.cpp.

References SgPointSet::Include(), GoBoard::IsValidPoint(), m_bd, m_partOfPrey, GoBoard::Occupied(), SgVector< T >::PushBack(), and SG_ASSERT.

Referenced by Ladder(), and PlayPreyMove().

int GoLadder::PlayHunterMove ( int  depth,
SgPoint  move,
SgPoint  lib1,
SgPoint  lib2,
const GoPointList adjBlk,
SgVector< SgPoint > *  sequence 
) [private]
int GoLadder::PlayPreyMove ( int  depth,
SgPoint  move,
SgPoint  lib1,
const GoPointList adjBlk,
SgVector< SgPoint > *  sequence 
) [private]
bool GoLadder::PointIsAdjToPrey ( SgPoint  p  )  [private]

Definition at line 88 of file GoLadder.cpp.

References m_partOfPrey, SG_NS, and SG_WE.

Referenced by BlockIsAdjToPrey(), and PlayPreyMove().

int GoLadder::PreyLadder ( int  depth,
SgPoint  lib1,
const GoPointList adjBlk,
SgVector< SgPoint > *  sequence 
) [private]
void GoLadder::ReduceToBlocks ( GoPointList stones  )  [private]

Member Data Documentation

GoBoard* GoLadder::m_bd [private]

Maximum move number before ladder should be aborted.

Definition at line 59 of file GoLadder.h.

Referenced by CheckMoveOverflow(), and InitMaxMoveNumber().

Definition at line 63 of file GoLadder.h.

Referenced by Ladder(), MarkStonesAsPrey(), PlayPreyMove(), and PointIsAdjToPrey().

Definition at line 65 of file GoLadder.h.

Referenced by Ladder(), and PlayPreyMove().

const int GoLadder::MAX_LADDER_MOVES = 200 [static, private]

Maximum number of moves in ladder.

If board has simple ko rule, ladders could not terminate.

Definition at line 56 of file GoLadder.h.

Referenced by InitMaxMoveNumber().


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


Sun Mar 13 2011 Doxygen 1.7.1