
	How to add a new Pattern


To add a new pattern edit src/patterns.dat.

Symbols in patterns.dat
=======================
  NOTE: Symbols must placed in begin of line.

;	Comment
#	Begin of pattern
	#Idnum Default_value [x_position y_position]
#.	End of patterns
>	Begin of Code for pattern
|	Pattern TYPE
	|PT_CENTER	Check for center only (Default)
	|PT_WHOLE	Check for entire board
	|PT_SIDE	Check for side only
	|PT_CORNER	Check for corder only


Symbols in pattern
==================
  NOTE: 'My' means current turn's, 'His' means opponent's

.	Empty point
O	My stone
o	My stone or empty
X	His stone
x	His stone or empty
S	Empty && My territory from scoreBoard
s	Empty && His territory from scoreBoard
T	Empty && My forcefield from claim
t	Empty && His forcefield from claim
%	Not empty
@	My next move


Coordinate on Pattern
=====================

 | (y,0) ... (x, y)
 |  ..         ..
 | (0,0) ... (x, 0)
 |   -- This side is border if Pattern type is PT_SIDE
 +- Here is Corner if Pattern type is PT_CORNER


Pre-defined Macros for Code
===========================

#define PXY(a, b)       get_px(x, a, b, pat, dir)][get_py(y, a, b, pat, dir)
	Get real position on board for array
	Usage:	INTBOARD[PXY(a,b)] --> INTBOARD[absX][absY]

#define PCXY(a, b)      get_px(x, a, b, pat, dir), get_py(y, a, b, pat, dir)
	Get real position on board for function
	Usage:	FNCTION(PCXY(a,b)) --> FUNCTION(absX, absY)

STRING(a, b)
	string on (a,b) from stringRec sList[]
	
LIBC(a, b)
	Liberty count for string on (a,b)

LIBB(a, b)      libBoard[PXY(a,  b)]

BORD(a, b)      bord[PXY(a, b)]
	0: empty, 1: my stone, -1: his stone

SCORE(a, b)     scoreBoard[PXY(a, b)]
	0: unknown
	2: My Territory
	1: Border of My Territory
	-1, -2: His....
	
CLAIM(a, b)     claim[PXY(a, b)]
	Positive: My force field

POW(a, b)       powerBoard[PXY(a,b)]
	How many claim[] changes for mine when placed my stone
POW1(a, b)	powerBoard1[PXY(a,b)]
	How many claim[] changes for mine when placed his stone
POW2(a, b)      powerBoard2[PXY(a,b)]
	(POW+ POW1) / 2

ISSAFE(a, b)    sList[gMap[stringIDs[PXY(a,b)]]].isSafe
ISDEAD(a, b)    sList[gMap[stringIDs[PXY(a,b)]]].isDead
	String on (a, b) is safe or dead.	

TRY_PLAY(a, b, c)       tryPlay(PCXY(a,b), c)
	Put a stone on (a, b) when 'c' is '1' put my stone, and
	when 'c' is '-1' put his stone.
	NOTE: When using TRY_PLAY you must call restoreState()

KILLABLE(a, b)          killable(PCXY(a,b), &xx, &yy)
SAVEABLE(a, b)          saveable(PCXY(a,b), &xx, &yy)
	String on (a,b) in pattern is killable or saveable.

PPOS(a,b)		Alternative Position

PERCENT(a)		(random() % 100) < a

Simple Pattern
==============

#Idnum Default_value
...........
..pattern..
...........

<Example>
#3 6
OX..
.@.O

- In this condition value of move on '@' is 6


Pattern with Code
=================
#104 8
|PT_SIDE
oX.*
O.@t
...t
> if (LIBC(0,1) < 3)
      value = 0;

- This pattern is for side.
  Defualt value is 8 but if Liberties of string on (0,1) is
less than 3 this move is useless(value = 0).


Complex Code
============
#Idnum default_value X_postion Y_postion

<Example>
#112 4 0 0
|PT_SIDE
*.Xo
t.Oo
> if (!ISSAFE(2,0) || LIBB(0,0) == 1)
    value = 0;
  else
    value += LIBB(0,0);

- This Pattern has no '@'.
  If you want check whose territory or forcefile of next move
indicate position like this.
  This Pattern's next move is (0, 0).

Alternative Position
====================
<Example>
#304 5.3
|PT_CORNER
......
..X...
....@.
......
......
> if (CLAIM(4, 2) > 4)
    value = 0;
  else if (PERCENT(30))
    PPOS(4,3);

- This patterns default position is '@'(4,2).
  Probability of alternative position (4,3) is 30%.

Tuning a new pattern
====================
After adding a new pattern you must test it works correctly.

