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

GoUctPatterns< BOARD > Class Template Reference

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

#include <GoUctPatterns.h>

List of all members.

Public Member Functions

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

Private Types

typedef SgArray< bool,
GOUCT_POWER3_5
GoUctEdgePatternTable
 See m_edgeTable.
typedef SgArray< bool,
GOUCT_POWER3_8
GoUctPatternTable
 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.

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 60 of file GoUctPatterns.h.


Member Typedef Documentation

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

See m_edgeTable.

Definition at line 76 of file GoUctPatterns.h.

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

See m_table.

Definition at line 79 of file GoUctPatterns.h.


Constructor & Destructor Documentation

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

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 158 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 167 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 145 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]
template<class BOARD>
int GoUctPatterns< BOARD >::CodeOfEdgeNeighbors ( const BOARD &  bd,
SgPoint  p 
) [static, private]
template<class BOARD>
int GoUctPatterns< BOARD >::EBWCodeOfPoint ( const BOARD &  bd,
SgPoint  p 
) [static, private]
template<class BOARD >
int GoUctPatterns< BOARD >::EdgeDirection ( GoBoard bd,
SgPoint  p,
int  index 
) [static, private]
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 254 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]
template<class BOARD >
void GoUctPatterns< BOARD >::InitEdgePatternTable ( SgBWArray< GoUctEdgePatternTable > &  edgeTable  )  [static, private]
template<class BOARD >
bool GoUctPatterns< BOARD >::MatchAny ( SgPoint  p  )  const
template<class BOARD >
bool GoUctPatterns< BOARD >::MatchAnyCenter ( SgPoint  p  )  const [private]

Match any of the center patterns.

Definition at line 494 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]
template<class BOARD >
bool GoUctPatterns< BOARD >::MatchAnyPattern ( const GoBoard bd,
SgPoint  p 
) [static, private]
template<class BOARD >
bool GoUctPatterns< BOARD >::MatchCut ( const GoBoard bd,
SgPoint  p 
) [static, private]
template<class BOARD >
bool GoUctPatterns< BOARD >::MatchEdge ( const GoBoard bd,
SgPoint  p,
const int  nuBlack,
const int  nuWhite 
) [static, private]
template<class BOARD >
bool GoUctPatterns< BOARD >::MatchHane ( const GoBoard bd,
SgPoint  p,
const int  nuBlack,
const int  nuWhite 
) [static, private]
template<class BOARD >
int GoUctPatterns< BOARD >::OtherDir ( int  dir  )  [static, private]
template<class BOARD >
int GoUctPatterns< BOARD >::SetupCodedEdgePosition ( GoBoard bd,
int  code 
) [static, private]
template<class BOARD >
int GoUctPatterns< BOARD >::SetupCodedPosition ( GoBoard bd,
int  code 
) [static, private]

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 70 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 73 of file GoUctPatterns.h.

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

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

lookup table on the edge of board

Definition at line 87 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 84 of file GoUctPatterns.h.

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


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


Sun Mar 13 2011 Doxygen 1.7.1