Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

GoUctPatterns< BOARD > Class Template Reference

#include <GoUctPatterns.h>

List of all members.


Detailed Description

template<class BOARD>
class GoUctPatterns< BOARD >

Some hard-coded pattern matching routines to match patterns used by MoGo.

See Modification of UCT with Patterns in Monte-Carlo Go.

The move is always in the center of the pattern or at the middle edge point (lower line) for edge patterns. The patterns are matched for both colors, unless specified otherwise. Notation:

    O  White            x = Black or Empty
    X = Black           o = White or Empty
    . = Empty           B = Black to Play
    ? = Don't care      W = White to Play
    

Patterns for Hane.
True is returned if any pattern is matched.

    X O X   X O .   X O ?   X O O
    . . .   . . .   X . .   . . .
    ? ? ?   ? . ?   ? . ?   ? . ? B
    

Patterns for Cut1.
True is returned if the first pattern is matched, but not the next two.

    X O ?   X O ?   X O ?
    O . ?   O . O   O . .
    ? ? ?   ? . ?   ? O ?
    

Pattern for Cut2.

    ? X ?
    O . O
    x x x
    

Pattern for Edge.
True is returned if any pattern is matched.

    X . ?   ? X ?   ? X O    ? X O    ? X O
    O . ?   o . O   ? . ? B  ? . o W  O . X W
    

Definition at line 62 of file GoUctPatterns.h.

Public Member Functions

 GoUctPatterns (const BOARD &bd)
bool MatchAny (SgPoint p) const
 Match any of the patterns.

Private Types

typedef SgArray< bool, GOUCT_POWER3_5GoUctEdgePatternTable
 See m_edgeTable.
typedef SgArray< bool, GOUCT_POWER3_8GoUctPatternTable
 See m_table.

Private Member Functions

bool MatchAnyCenter (SgPoint p) const
 Match any of the center patterns.
bool MatchAnyEdge (SgPoint p) const
 Match any of the edge patterns.

Static Private Member Functions

static bool CheckCut1 (const GoBoard &bd, SgPoint p, SgBlackWhite c, int cDir, int otherDir)
static bool CheckCut2 (const GoBoard &bd, SgPoint p, const SgBlackWhite c, int cDir, int otherDir)
static bool CheckHane1 (const GoBoard &bd, SgPoint p, SgBlackWhite c, SgBlackWhite opp, int cDir, int otherDir)
static int CodeOf8Neighbors (const BOARD &bd, SgPoint p)
static int CodeOfEdgeNeighbors (const BOARD &bd, SgPoint p)
static int EdgeDirection (GoBoard &bd, SgPoint p, int index)
static int EBWCodeOfPoint (const BOARD &bd, SgPoint p)
static int FindDir (const GoBoard &bd, SgPoint p, SgBlackWhite c)
 Find direction of a neighboring stone in color c.
static void InitCenterPatternTable (SgBWArray< GoUctPatternTable > &table)
static void InitEdgePatternTable (SgBWArray< GoUctEdgePatternTable > &edgeTable)
static bool MatchCut (const GoBoard &bd, SgPoint p)
static bool MatchEdge (const GoBoard &bd, SgPoint p, const int nuBlack, const int nuWhite)
static bool MatchHane (const GoBoard &bd, SgPoint p, const int nuBlack, const int nuWhite)
static bool MatchAnyPattern (const GoBoard &bd, SgPoint p)
 Procedural matching function - used to initialize the table.
static int OtherDir (int dir)
static int SetupCodedEdgePosition (GoBoard &bd, int code)
static int SetupCodedPosition (GoBoard &bd, int code)

Private Attributes

const BOARD & m_bd
SgBWArray< GoUctPatternTablem_table
 lookup table for 8-neighborhood of a move candidate
SgBWArray< GoUctEdgePatternTablem_edgeTable
 lookup table on the edge of board

Static Private Attributes

static const int GOUCT_POWER3_5 = 3 * 3 * 3 * 3 * 3
 3^5 = size of edge pattern table
static const int GOUCT_POWER3_8 = 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3
 3^8 = size of center pattern table.


Member Typedef Documentation

template<class BOARD>
typedef SgArray<bool, GOUCT_POWER3_5> GoUctPatterns< BOARD >::GoUctEdgePatternTable [private]

See m_edgeTable.

Definition at line 78 of file GoUctPatterns.h.

template<class BOARD>
typedef SgArray<bool, GOUCT_POWER3_8> GoUctPatterns< BOARD >::GoUctPatternTable [private]

See m_table.

Definition at line 81 of file GoUctPatterns.h.


Constructor & Destructor Documentation

template<class BOARD>
GoUctPatterns< BOARD >::GoUctPatterns ( const BOARD &  bd  ) 

Definition at line 139 of file GoUctPatterns.h.

References GoUctPatterns< BOARD >::InitCenterPatternTable(), GoUctPatterns< BOARD >::InitEdgePatternTable(), GoUctPatterns< BOARD >::m_edgeTable, and GoUctPatterns< BOARD >::m_table.


Member Function Documentation

template<class BOARD>
bool GoUctPatterns< BOARD >::CheckCut1 ( const GoBoard bd,
SgPoint  p,
SgBlackWhite  c,
int  cDir,
int  otherDir 
) [static, private]

Definition at line 160 of file GoUctPatterns.h.

References GoBoard::IsColor(), SG_ASSERT_BW, and SgOppBW().

Referenced by GoUctPatterns< BOARD >::MatchCut().

template<class BOARD>
bool GoUctPatterns< BOARD >::CheckCut2 ( const GoBoard bd,
SgPoint  p,
const SgBlackWhite  c,
int  cDir,
int  otherDir 
) [static, private]

Definition at line 169 of file GoUctPatterns.h.

References GoBoard::IsColor(), SG_ASSERT, SG_ASSERT_BW, and SgOppBW().

Referenced by GoUctPatterns< BOARD >::MatchCut().

template<class BOARD>
bool GoUctPatterns< BOARD >::CheckHane1 ( const GoBoard bd,
SgPoint  p,
SgBlackWhite  c,
SgBlackWhite  opp,
int  cDir,
int  otherDir 
) [static, private]

Definition at line 147 of file GoUctPatterns.h.

References GoBoard::IsColor(), and GoBoard::IsEmpty().

Referenced by GoUctPatterns< BOARD >::MatchHane().

template<class BOARD>
int GoUctPatterns< BOARD >::CodeOf8Neighbors ( const BOARD &  bd,
SgPoint  p 
) [static, private]

Definition at line 190 of file GoUctPatterns.h.

References GoUctPatterns< BOARD >::EBWCodeOfPoint(), GoUctPatterns< BOARD >::GOUCT_POWER3_8, SG_ASSERT, SG_NS, and SG_WE.

Referenced by GoUctPatterns< BOARD >::MatchAnyCenter().

template<class BOARD>
int GoUctPatterns< BOARD >::CodeOfEdgeNeighbors ( const BOARD &  bd,
SgPoint  p 
) [static, private]

Definition at line 207 of file GoUctPatterns.h.

References GoUctPatterns< BOARD >::EBWCodeOfPoint(), GoUctPatterns< BOARD >::GOUCT_POWER3_5, GoUctPatterns< BOARD >::OtherDir(), and SG_ASSERT.

Referenced by GoUctPatterns< BOARD >::MatchAnyEdge().

template<class BOARD>
int GoUctPatterns< BOARD >::EBWCodeOfPoint ( const BOARD &  bd,
SgPoint  p 
) [static, private]

Definition at line 225 of file GoUctPatterns.h.

References BOOST_STATIC_ASSERT(), SG_ASSERT, SG_BLACK, SG_EMPTY, and SG_WHITE.

Referenced by GoUctPatterns< BOARD >::CodeOf8Neighbors(), and GoUctPatterns< BOARD >::CodeOfEdgeNeighbors().

template<class BOARD>
int GoUctPatterns< BOARD >::EdgeDirection ( GoBoard bd,
SgPoint  p,
int  index 
) [static, private]

Definition at line 235 of file GoUctPatterns.h.

References GoUctPatterns< BOARD >::OtherDir(), SG_ASSERT, and GoBoard::Up().

Referenced by GoUctPatterns< BOARD >::SetupCodedEdgePosition().

template<class BOARD>
int GoUctPatterns< BOARD >::FindDir ( const GoBoard bd,
SgPoint  p,
SgBlackWhite  c 
) [static, private]

Find direction of a neighboring stone in color c.

Definition at line 256 of file GoUctPatterns.h.

References GoBoard::IsColor(), SG_ASSERT, SG_NS, and SG_WE.

Referenced by GoUctPatterns< BOARD >::MatchHane().

template<class BOARD>
void GoUctPatterns< BOARD >::InitCenterPatternTable ( SgBWArray< GoUctPatternTable > &  table  )  [static, private]

Definition at line 289 of file GoUctPatterns.h.

References GoUctPatterns< BOARD >::GOUCT_POWER3_8, GoUctPatterns< BOARD >::MatchAnyPattern(), SgPointUtil::Pt(), GoBoard::SetToPlay(), GoUctPatterns< BOARD >::SetupCodedPosition(), and GoBoard::Undo().

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

template<class BOARD>
void GoUctPatterns< BOARD >::InitEdgePatternTable ( SgBWArray< GoUctEdgePatternTable > &  edgeTable  )  [static, private]

Definition at line 270 of file GoUctPatterns.h.

References GoUctPatterns< BOARD >::GOUCT_POWER3_5, GoUctPatterns< BOARD >::MatchAnyPattern(), SgPointUtil::Pt(), GoBoard::SetToPlay(), GoUctPatterns< BOARD >::SetupCodedEdgePosition(), and GoBoard::Undo().

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

template<class BOARD>
bool GoUctPatterns< BOARD >::MatchAny ( SgPoint  p  )  const

Match any of the patterns.

Definition at line 508 of file GoUctPatterns.h.

References GoUctPatterns< BOARD >::m_bd, GoUctPatterns< BOARD >::MatchAnyCenter(), GoUctPatterns< BOARD >::MatchAnyEdge(), SG_BLACK, and SG_WHITE.

Referenced by GoUctCommands::CmdPatterns().

template<class BOARD>
bool GoUctPatterns< BOARD >::MatchAnyCenter ( SgPoint  p  )  const [private]

Match any of the center patterns.

Definition at line 496 of file GoUctPatterns.h.

References GoUctPatterns< BOARD >::CodeOf8Neighbors(), GoUctPatterns< BOARD >::m_bd, and GoUctPatterns< BOARD >::m_table.

Referenced by GoUctPatterns< BOARD >::MatchAny().

template<class BOARD>
bool GoUctPatterns< BOARD >::MatchAnyEdge ( SgPoint  p  )  const [private]

Match any of the edge patterns.

Definition at line 502 of file GoUctPatterns.h.

References GoUctPatterns< BOARD >::CodeOfEdgeNeighbors(), GoUctPatterns< BOARD >::m_bd, and GoUctPatterns< BOARD >::m_edgeTable.

Referenced by GoUctPatterns< BOARD >::MatchAny().

template<class BOARD>
bool GoUctPatterns< BOARD >::MatchAnyPattern ( const GoBoard bd,
SgPoint  p 
) [static, private]

Procedural matching function - used to initialize the table.

Definition at line 526 of file GoUctPatterns.h.

References GoBoard::IsEmpty(), GoBoard::Line(), GoUctPatterns< BOARD >::MatchCut(), GoUctPatterns< BOARD >::MatchEdge(), GoUctPatterns< BOARD >::MatchHane(), GoBoard::NumNeighbors(), GoBoard::Pos(), SG_ASSERT, SG_BLACK, and SG_WHITE.

Referenced by GoUctPatterns< BOARD >::InitCenterPatternTable(), and GoUctPatterns< BOARD >::InitEdgePatternTable().

template<class BOARD>
bool GoUctPatterns< BOARD >::MatchCut ( const GoBoard bd,
SgPoint  p 
) [static, private]

Definition at line 308 of file GoUctPatterns.h.

References GoUctPatterns< BOARD >::CheckCut1(), GoUctPatterns< BOARD >::CheckCut2(), GoBoard::GetColor(), GoBoard::Num8EmptyNeighbors(), GoBoard::NumDiagonals(), GoBoard::NumEmptyNeighbors(), GoBoard::NumNeighbors(), SG_EMPTY, SG_NS, SG_WE, and SgOppBW().

Referenced by GoUctPatterns< BOARD >::MatchAnyPattern().

template<class BOARD>
bool GoUctPatterns< BOARD >::MatchEdge ( const GoBoard bd,
SgPoint  p,
const int  nuBlack,
const int  nuWhite 
) [static, private]

Definition at line 353 of file GoUctPatterns.h.

References GoBoard::GetColor(), GoBoard::NumDiagonals(), GoBoard::NumEmptyNeighbors(), GoBoard::NumNeighbors(), GoUctPatterns< BOARD >::OtherDir(), SG_BLACK, SG_EMPTY, SG_WHITE, SgOppBW(), GoBoard::ToPlay(), and GoBoard::Up().

Referenced by GoUctPatterns< BOARD >::MatchAnyPattern().

template<class BOARD>
bool GoUctPatterns< BOARD >::MatchHane ( const GoBoard bd,
SgPoint  p,
const int  nuBlack,
const int  nuWhite 
) [static, private]

Definition at line 423 of file GoUctPatterns.h.

References GoUctPatterns< BOARD >::CheckHane1(), GoUctPatterns< BOARD >::FindDir(), GoBoard::GetColor(), GoBoard::IsColor(), GoBoard::IsEmpty(), GoBoard::NumDiagonals(), GoBoard::NumEmptyNeighbors(), GoUctPatterns< BOARD >::OtherDir(), SG_ASSERT, SG_BLACK, SG_EMPTY, SG_NS, SG_WE, SG_WHITE, SgOppBW(), and GoBoard::ToPlay().

Referenced by GoUctPatterns< BOARD >::MatchAnyPattern().

template<class BOARD>
int GoUctPatterns< BOARD >::OtherDir ( int  dir  )  [static, private]

Definition at line 548 of file GoUctPatterns.h.

References SG_NS, and SG_WE.

Referenced by GoUctPatterns< BOARD >::CodeOfEdgeNeighbors(), GoUctPatterns< BOARD >::EdgeDirection(), GoUctPatterns< BOARD >::MatchEdge(), and GoUctPatterns< BOARD >::MatchHane().

template<class BOARD>
int GoUctPatterns< BOARD >::SetupCodedEdgePosition ( GoBoard bd,
int  code 
) [static, private]

Definition at line 556 of file GoUctPatterns.h.

References GoUctPatterns< BOARD >::EdgeDirection(), GoBoard::Play(), SgPointUtil::Pt(), and SG_EMPTY.

Referenced by GoUctPatterns< BOARD >::InitEdgePatternTable().

template<class BOARD>
int GoUctPatterns< BOARD >::SetupCodedPosition ( GoBoard bd,
int  code 
) [static, private]

Definition at line 575 of file GoUctPatterns.h.

References SgNb8Iterator::Direction(), GoBoard::Play(), SgPointUtil::Pt(), and SG_EMPTY.

Referenced by GoUctPatterns< BOARD >::InitCenterPatternTable().


Member Data Documentation

template<class BOARD>
const int GoUctPatterns< BOARD >::GOUCT_POWER3_5 = 3 * 3 * 3 * 3 * 3 [static, private]

3^5 = size of edge pattern table

Definition at line 72 of file GoUctPatterns.h.

Referenced by GoUctPatterns< BOARD >::CodeOfEdgeNeighbors(), and GoUctPatterns< BOARD >::InitEdgePatternTable().

template<class BOARD>
const int GoUctPatterns< BOARD >::GOUCT_POWER3_8 = 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 [static, private]

3^8 = size of center pattern table.

Definition at line 75 of file GoUctPatterns.h.

Referenced by GoUctPatterns< BOARD >::CodeOf8Neighbors(), and GoUctPatterns< BOARD >::InitCenterPatternTable().

template<class BOARD>
const BOARD& GoUctPatterns< BOARD >::m_bd [private]

Definition at line 83 of file GoUctPatterns.h.

Referenced by GoUctPatterns< BOARD >::MatchAny(), GoUctPatterns< BOARD >::MatchAnyCenter(), and GoUctPatterns< BOARD >::MatchAnyEdge().

template<class BOARD>
SgBWArray<GoUctEdgePatternTable> GoUctPatterns< BOARD >::m_edgeTable [private]

lookup table on the edge of board

Definition at line 89 of file GoUctPatterns.h.

Referenced by GoUctPatterns< BOARD >::GoUctPatterns(), and GoUctPatterns< BOARD >::MatchAnyEdge().

template<class BOARD>
SgBWArray<GoUctPatternTable> GoUctPatterns< BOARD >::m_table [private]

lookup table for 8-neighborhood of a move candidate

Definition at line 86 of file GoUctPatterns.h.

Referenced by GoUctPatterns< BOARD >::GoUctPatterns(), and GoUctPatterns< BOARD >::MatchAnyCenter().


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


17 Jun 2010 Doxygen 1.4.7