
'*******************************************************
'                    N O m e g a
'
'               a weak chess program
'            by Chris Tatham (c)2005-11
'*******************************************************


'NB This is internal version Nomega1 based on v 5_11_11_2

'*******************************************************
'   The core winboard interface code is written by
'   Tom McBurney and is used here with his permission.
'   Its integration within NOmega is my own and any
'   resulting errors are my responsibility
'*******************************************************

#Lang "fblite"
Option NoKeyWord Time

'The following functions are used for communicating with Winboard
declare function GetCommand() as string
declare function SendCommand(byval WBCmd as string) as integer
DECLARE SUB WaitForWinboard

' Declare the API functions we will be using for communicating to Winboard
DIM KernelLib AS Any Ptr
dim shared WriteFile as function (BYVAL hFile AS integer, lpBuffer AS ANY, BYVAL nNumberOfBytesToWrite AS integer, lpNumberOfBytesWritten AS integer, lpOverlapped AS ANY) AS integer
dim shared GetStdHandle as function (BYVAL nStdHandle AS integer) AS integer
dim shared ReadFile as function (BYVAL hFile AS integer, lpBuffer AS ANY, BYVAL nNumberOfBytesToRead AS integer, lpNumberOfBytesRead AS integer, lpOverlapped AS ANY) AS integer
dim shared PeekNamedPipe as function (BYVAL hNamedPipe AS integer, lpBuffer AS ANY, BYVAL nBufferSize AS integer, lpBytesRead AS integer, lpTotalBytesAvail AS integer, lpBytesLeftThisMessage AS integer) AS integer

' Link KernelLib to kernel32.dll
KernelLib = dylibload("KERNEL32")

' Link the functions to the appropriate Kernel32 library.
WriteFile = dylibsymbol(KernelLib, "WriteFile")
GetStdHandle = dylibsymbol(KernelLib, "GetStdHandle")
ReadFile = dylibsymbol(KernelLib, "ReadFile")
PeekNamedPipe = dylibsymbol(KernelLib, "PeekNamedPipe")

DIM STD_OUTPUT_HANDLE AS integer
DIM STD_INPUT_HANDLE AS integer
DIM shared OutputHandle AS integer
DIM shared InputHandle AS integer

STD_OUTPUT_HANDLE = -11&
STD_INPUT_HANDLE = -10&

OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE)
InputHandle = GetStdHandle(STD_INPUT_HANDLE)


DIM sTemp AS STRING
DIM sWBCmd AS STRING
DIM SHARED WinboardMode AS INTEGER
DIM SHARED ForceMode AS INTEGER

WinboardMode = 0 '0 = console mode; 1 = winboard mode
ForceMode = 0



Initialise:

'***********************************
' Initialise key variables
'***********************************
Dim shared B(119) 'Array for 10x12 board
Dim shared u$(98) 'Array to display the board
Dim shared As single best_score, score,alpha, beta, eval, EV
'dim shared AS single alpha, beta

Dim shared Pseu_Moves(100) '100 number of pseudo moves per depth
dim shared max_depth = 15 ' max_search_depth
Dim shared depth = 15 ' depth

Dim shared temp_val1(depth)
dim shared epsqr(depth) 'ep square



declare function gen_move(side,depth,epsqr(),w_casflags(),b_casflags())
declare function incheck(side)
declare function make_move(side,Depth,Pseu_Moves(),y,epsqr(),w_casflags(),b_casflags(), wprom(),bprom(),fmove())
declare function unmake_move(side,Depth,Pseu_Moves(),y,temp_val1(),epsqr(),w_casflags(),b_casflags(),wprom(),bprom(),fmove())

declare function attack(side,ps)
declare function display()
declare function user_entry()
declare function user_move(MoveFrom,MoveTo,side)
declare function computer_move(side)
declare function ab_search(side,depth,Alpha  AS single, beta  AS single, epsqr(),w_casflags(),b_casflags(),fmove()) AS SINGLE
declare function evaluate(side) AS SINGLE
declare function assessboard(side,best_score AS SINGLE)
declare function QS(Vo,side)
declare function ending()
declare function open_book()
declare function help()
declare function SaveGame()
declare function LoadGame()
declare function rep_check(side)
declare function clear_board()

'declare function undo() 'not yet implemented

Dim shared B$(100) 'Book string
B$(1) = "P":B$(2)="N":B$(3)="B":B$(4)="R":B$(6)="Q":B$(7)="K"
B$(19) = "p":B$(18)="n":B$(17)="b":B$(16)="r":B$(14)="q":B$(13)="k"


Dim shared perft
dim shared MoveFrom, Moveto
dim shared act_epsq ' actual ep-square value (ie post-move)
Dim shared O$ ' string to hold input for fen parsing
declare function fen(O$)
dim shared nodes_root_move AS LONGINT
dim shared search_depth

M_N = 80: MT_F_SM = 3 'M_N = maximum move numbers; MT_F_SM = special moves- ie to record promotion & capture
Dim shared Move_list(Depth, M_N,MT_F_SM) ' array to hold all generated moves
Dim shared Move_list_root(Depth, M_N,MT_F_SM) ' array used to bublle sort root moves
Dim shared Move_list_temp(Depth, M_N,MT_F_SM) ' temp array used for bubble sort of root moves

Dim shared nodes AS LONGINT

Dim shared wkloc = 25, bkloc = 95  ' nb will need to move this and adjust for board rotation with colour
Dim shared Move_Offset(16), Pawn_Offset(4) ' move-offset arrays to reflect all possible move combinations

' ***** piece values for board representation *****
Dim shared King = 7, Queen = 6, Rook = 4, Bishop = 3, Knight = 2, Pawn = 1

'***** piece values for evaluation *****
Dim shared Pawn_Value = 100, Knight_Value = 300, Bishop_Value = 325, Rook_Value = 500, Queen_Value = 950

'***** arrays for piece square tables (PST)
Dim shared WP_PST(100),BP_PST(100), WKt_PST(100), BKt_PST(100),WBp_PST(100),BBp_PST(100),WRk_PST(100),BRk_PST(100),WQn_PST(100),BQn_PST(100),WKg_PST(100),BKg_PST(100),BKg_end_PST(100), WKg_end_PST(100)
Dim shared K_r_end_PST(100),WP_end_PST(100),BP_end_PST(100)

'***** other variables *****
Dim shared side
Dim shared White = 1, Black = -1
Dim shared True = 1, False = 0
Dim shared computer = 1, opponent = -1
dim shared STM ' side to move flag
Dim shared wprom(depth),bprom(depth)
dim shared w_cas(2), b_cas(2) ' black/white castling status - actual values
w_cas(1) = 0:w_cas(2) = 0:b_cas(1) = 0:b_cas(2) = 0 ' 1 = king-side; 2 = queen-side; 0 = castling possible (default val)

Dim shared w_casflags(depth,2),b_casflags(depth,2)
' white & black castle flags in search  '1 = O-O; 2 = O-O-O
'                             vals: -1 no castle, 0 - available, 1 - done!

w_casflags(depth,1) = 0:w_casflags(depth,2) = 0
b_casflags(depth,1) = 0:b_casflags(depth,2) = 0

dim shared pr$ '- computer promotion piece
dim shared cmpclr   ' 1 - comp = white' -1 - comp = black
Dim shared Flipboard(120) ' array used for flipping board values when colours switched
Dim shared MoveNo = 0
Dim shared No_Pieces = 32
dim shared WQ = 1, BQ = 1, wr = 2, br = 2 ' No queens/rooks (used for endgame eval testing)
dim shared Bbp, Wbp, Bkn, Wkn ' vars used for insufficient material test (Bbp = Black bishop etc)
side = white   'assume playing white
cmpclr = -1  ' therefore computer is black (ie -1); computer playing white = 1
dim shared IM 'insufficient material flag
dim shared fifty_move = 0
dim shared fmove(depth) ' keep track of 50 move increment during search
dim shared move_hist(220,4) 'max number moves 200 store movefrom - to for both colours
dim shared Pos_State_W$(220), Pos_State_B$(220)  'hold board position for each move for black & white (repetition detection)
dim shared post = 0 ' assume no posting of PV for winboard unless conditions met later

Dim shared AS single t1,t2, accum 'variables to keep track of time used
dim shared start_time, move_control, game_time, time_left, think_time, conv_clock = 0, inc, t_move, break_move, av_think_time, timed_out ' vars to handle time management
'dim shared start_time
dim Shared conv_clock_move_no = 0  ' variable to keep track of moves for timing purposes where increment = 0
dim shared fix_depth = 0 ' flag to indicate if fixed depth search should be carried out
dim shared bookhit ' 1 = bookmove found ; 0 = not found!
dim shared display_node ' var for showing nodes searched  if post variable is set
dim shared init_swp_val ' initial swap off value - set in make move
dim shared cap_sq ' initial capture square for swap off - set in make move
dim shared temp_root_move_val 'temp to test
dim shared stand_pat AS SINGLE 'eval used in swap off calculation, to determine whether capture is worthwhile
Dim shared ENDGAME ' 0 = not endgame; 1 = endgame
Dim shared prom_depth AS SINGLE
dim shared Mat_left ' count of material on board - to determine endgame phase
Mat_left = ((Bishop_Value + Knight_Value) * 4) + (Rook_Value * 4) + (Queen_Value * 2) ' total material @ game start
dim shared orig_root ' number moves at root - used for in search time checks
dim shared it_depth ' iterative search depth

'-------------------------------------------------------------------------------

'**********************************************************
' Define ChessBoard with initial position
'
' board is represented by standard 10 x 12 array
' initial position is populated via Read/Data
' dummy (-99) is used to represent positions off the board
'**********************************************************

FOR BoardArray = 0 TO 119
	B(BoardArray) = -99
NEXT BoardArray

FOR X = 9 TO 2 STEP -1
	FOR Y = 1 TO 8
		READ Board
		B(X*10+Y) = Board
		if Board = 7 Then
			wkloc = X*10+Y 
		ElseIf Board = -7 Then
			bkloc = X*10+Y 'temp line to allow non-fen position set-up
		EndIf
	NEXT 
NEXT 

' initial position values

DATA  -4, -2, -3, -6, -7, -3, -2, -4
DATA  -1, -1, -1, -1, -1, -1, -1, -1
DATA   0,  0,  0,  0,  0,  0,  0,  0
DATA   0,  0,  0,  0,  0,  0,  0,  0
DATA   0,  0,  0,  0,  0,  0,  0,  0
DATA   0,  0,  0,  0,  0,  0,  0,  0
DATA   1,  1,  1,  1,  1,  1,  1,  1
DATA   4,  2,  3,  6,  7,  3,  2,  4


'***********************************************************
' establish move offsets - ie movement directions on board
'   Data 1 - 4  = sliders (diagonal)
'   Data 5 - 8  = slider (horizontal/vertical)
'   Data 9 - 16 = jumper (ie knight moves)
'
'   pawn offsets are for non-capture moves
'***********************************************************

FOR K = 1 TO 16
	READ Move_Offset(K)
NEXT K

DATA 11,9,-11,-9,-10,-1,1,10,-21,-19,-8,-12,8,12,19,21

For K = 1 TO 4
	Read Pawn_Offset(K)
NEXT K

DATA 20,10,-20,-10


'***********************************************************
' establish piece square table values for each piece, using
' separate values for the endgame
'
' values with further refinement and further development
' are based on those given on
' http://chessprogramming.wikispaces.com/
'***********************************************************


FOR X = 9 TO 2 STEP -1
	FOR Y = 1 TO 8
		READ WhitePawn_PST
		WP_PST(X*10+Y) = WhitePawn_PST
	NEXT Y
NEXT X


DATA  0,  0,  0,  0,  0,  0,  0,  0
DATA 50, 50, 50, 50, 50, 50, 50, 50
DATA 10, 10, 20, 35, 35, 20, 10, 10
DATA  5,  5, 10, 30, 30, 10,  5,  5
DATA  0,  0,  0, 25, 25,  0,  0,  0
DATA  5, -5,-10,  0,  0,-10, -5,  5
DATA  5, 10, 10,-25,-25, 10, 10,  5
DATA  0,  0,  0,  0,  0,  0,  0,  0



FOR X = 9 TO 2 STEP -1
	FOR Y = 1 TO 8
		READ W_Pawn_end_PST
		WP_end_PST(X*10+Y) = W_Pawn_end_PST
	NEXT Y
NEXT X


DATA   0,  0,  0,  0,  0,  0,  0,  0
DATA  50, 50, 50, 50, 50, 50, 50, 50
DATA  20, 20, 20, 20, 20, 20, 20, 20
DATA  10, 10, 10, 10, 10, 10, 10, 10
DATA   5,  5,  5,  5,  5,  5,  5,  5
DATA   0,  0,  0,  0,  0,  0,  0,  0
DATA   0,  0,  0,  0,  0,  0,  0,  0
DATA   0,  0,  0,  0,  0,  0,  0,  0


FOR X = 9 TO 2 STEP -1
	FOR Y = 1 TO 8
		READ WhiteKnight_PST
		WKt_PST(X*10+Y) = WhiteKnight_PST
	NEXT Y
NEXT X

DATA -40,-30,-20,-20,-20,-20,-30,-40
DATA -35,-20,  0,  5,  5,  0,-20,-35
DATA -25,  0, 10, 15, 15, 10,  0,-25
DATA -25,  5, 15, 20, 20, 15,  5,-25
DATA -25,  0, 15, 20, 20, 15,  0,-25
DATA -25,  5, 10, 15, 15, 10,  5,-25
DATA -35,-20,  0,  5,  5,  0,-20,-35
DATA -60,-40,-30,-30,-30,-30,-40,-60


FOR X = 9 TO 2 STEP -1
	FOR Y = 1 TO 8
		READ WhiteBishop_PST
		WBp_PST(X*10+Y) = WhiteBishop_PST
	NEXT Y
NEXT X

DATA -20,-10,-10,-10,-10,-10,-10,-20
DATA  -5,  0,  0,  0,  0,  0,  0, -5
DATA  -5,  0,  5, 10, 10,  5,  0, -5
DATA  -5,  5,  5, 10, 10,  5,  5, -5
DATA  -5,  0, 10, 10, 10, 10,  0, -5
DATA  -5, 10, 10, 10, 10, 10, 10, -5
DATA  -5,  5,  0,  0,  0,  0,  5, -5
DATA -20,-15,-15,-15,-15,-15,-15,-20


FOR X = 9 TO 2 STEP -1
	FOR Y = 1 TO 8
		READ WhiteRook_PST
		WRk_PST(X*10+Y) = WhiteRook_PST
	NEXT Y
NEXT X

DATA   5,  5,  5,  5,  5,  5,  5,  5
DATA  10, 15, 15, 15, 15, 15, 15, 10
DATA  -5,  0,  0,  0,  0,  0,  0, -5
DATA  -5,  0,  0,  0,  0,  0,  0, -5
DATA  -5,  0,  0,  0,  0,  0,  0, -5
DATA  -5,  0,  0,  0,  0,  0,  0, -5
DATA  -5,  0,  0,  0,  0,  0,  0, -5
DATA   0,  0,  2,  5,  5,  2,  0,  0


FOR X = 9 TO 2 STEP -1
	FOR Y = 1 TO 8
		READ WhiteQueen_PST
		WQn_PST(X*10+Y) = WhiteQueen_PST
	NEXT Y
NEXT X

DATA -15,-10,-10, -5, -5,-10,-10,-15
DATA -10,  0,  0,  0,  0,  0,  0,-10
DATA -10,  0,  5,  5,  5,  5,  0,-10
DATA  -5,  0,  5,  5,  5,  5,  0, -5
DATA  -5,  0,  5,  5,  5,  5,  0, -5
DATA -10,  5,  5,  5,  5,  5,  0,-10
DATA -10,  0,  5,  0,  0,  0,  0,-10
DATA -20,-10,-10, -5, -5,-10,-10,-20

FOR X = 9 TO 2 STEP -1
	FOR Y = 1 TO 8
		READ WhiteKing_PST
		WKg_PST(X*10+Y) = WhiteKing_PST
	NEXT Y
NEXT X

DATA -30,-40,-40,-50,-50,-40,-40,-30
DATA -30,-40,-40,-50,-50,-40,-40,-30
DATA -30,-40,-40,-50,-50,-40,-40,-30
DATA -30,-40,-40,-50,-50,-40,-40,-30
DATA -20,-30,-30,-40,-40,-30,-30,-20
DATA -15,-20,-20,-20,-20,-20,-20,-15
DATA  15, 15,  0,  0,  0,  0, 15, 15
DATA  20, 35, 10,  0,  0, 10, 35, 20

FOR X = 9 TO 2 STEP -1
	FOR Y = 1 TO 8
		READ WK_End_PST
		WKg_end_PST(X*10+Y) = WK_End_PST
	NEXT Y
NEXT X

DATA -40,-35,-30,-20,-20,-30,-35,-40
DATA -30,-20,  0,  0,  0,  0,-20,-30
DATA -30,-10, 20, 30, 30, 20,-10,-30
DATA -30,-10, 30, 40, 40, 30,-10,-30
DATA -30,-10, 30, 40, 40, 30,-10,-30
DATA -30,-10, 20, 30, 30, 20,-10,-30
DATA -30,-30,  0,  0,  0,  0,-30,-30
DATA -55,-30,-30,-30,-30,-30,-30,-55


'*** Special PST for king in KvR/Q endgames
FOR X = 9 TO 2 STEP -1
	FOR Y = 1 TO 8
		READ K_r
		K_r_end_PST(X*10+Y) = K_r
	NEXT Y
NEXT X

DATA 50, 70, 100, 100, 100, 100, 70, 50
DATA 70, 40, 40, 40, 40, 40, 40, 70
DATA 100, 40, 20, 20, 20, 20, 40, 100
DATA 100, 40, 20, -20, -20, 20, 40, 100
DATA 100, 40, 20, -20, -20, 20, 40, 100
DATA 100, 40, 20, 20, 20, 20, 40, 100
DATA 70, 40, 40, 40, 40, 40, 40, 70
DATA 50, 70, 100, 100, 100, 100, 70, 50


FOR X = 2 TO 9                  ' reverse weights for black
	FOR Y = 1 TO 8
		BP_PST(X*10+Y) = WP_PST((-X+11)*10+Y)
		BP_end_PST(X*10+Y) = WP_end_PST((-X+11)*10+Y)
		BKt_PST(X*10+Y) = WKt_PST((-X+11)*10+Y)
		BBp_PST(X*10+Y) = WBp_PST((-X+11)*10+Y)
		BRk_PST(X*10+Y) = WRk_PST((-X+11)*10+Y)
		BQn_PST(X*10+Y) = WQn_PST((-X+11)*10+Y)
		BKg_PST(X*10+Y) = WKg_PST((-X+11)*10+Y)
		BKg_end_PST(X*10+Y) = WKg_end_PST((-X+11)*10+Y)
	NEXT Y
NEXT X


''/////////////////////////////////////////////////////////////////////////////

'--------------------------------------------------------------------------

'*************************************
' test if using GUI or console mode
'*************************************


CALL WaitForWinboard
IF WinboardMode = 1 THEN
	CommandLoop:
	' Process commands from Winboard.

	DO
		SLEEP 50
		sWBCmd = GetCommand

		IF sWBCmd = "protover 2" THEN
			sTemp = "feature myname=" + CHR$(34) + "N_O_m_e_g_a" + CHR$(34) + " sigint=0 sigterm=0 reuse=0 analyze=0 setboard=1 name=0"
			SendCommand (sTemp)
			SendCommand ("feature done=1")
		ELSEIF sWBCmd = "quit" THEN
			EXIT DO
		ELSEIF sWBCmd = "white" THEN
			side = white
			cmpclr =-1
		ELSEIF sWBCmd = "black" THEN
			side = black
			cmpclr = 1
		ELSEIF sWBCmd = "force" THEN
			ForceMode = 1
		ELSEIF sWBCmd = "go" THEN
			ForceMode = 0
			if MoveNo > 8 then
				call computer_move(side)
			elseif open_book() = false then
				call computer_move(side)
			end if
			side = -side
		ELSEIF sWBCmd = "post" THEN
			post = 1
			'ELSEIF sWBCmd = "undo" THEN
			' call undo()
		ELSEIF Left$(sWBCmd,8) = "setboard" THEN
			O$ = sWBCmd
			call fen(O$)
		ELSEIF Left$(sWBCmd,5) = "level" then
			fix_depth = 0
			c1$ = Mid$(sWBCmd,6)
			d1$ = Mid$(c1$,4)
			Move_control = VALINT(c1$)
			tim = valint(d1$)
			if right(SWBCmd,2) = " 0" then conv_clock = 1 else conv_clock = 0
			if conv_clock = 0 then inc = valint(right(c1$,2)) * 100
			game_time = tim * 60 * 100
		ELSEIF left$(sWBCmd,3) = "sd " then  'handle fix depth search
			fix_depth = 1
			conv_clock = 99
			e1$ = Mid$(sWBCmd,4)
			max_depth = VALINT(e1$)
		ELSEIF left$(sWBCmd,4) = "time" then
			c2$ = mid$(sWBCmd,5)
			time_left = valint(c2$)
			'  Print "time_left = ";time_left
			if conv_clock = 1 and Move_Control <> 0 and conv_clock_move_no = Move_Control then conv_clock_move_no = 0 ' if made t/c then reset move counter
			'line below added 18/6/2010 to take account of setboard cases where ccmn > Move control - eg set position at move 69 for 40/1 time control crashed
			if conv_clock = 1 and Move_Control <> 0 and (conv_clock_move_no > Move_Control) then conv_clock_move_no = conv_clock_move_no - Move_Control
			' if conv_clock = 1 then print" TLEFT = "; time_left; " MC = ";Move_Control; " ccmn = ";conv_clock_move_no
			if conv_clock = 1 and Move_Control <> 0 then
				think_time = (0.95 * (time_left/(Move_Control-conv_clock_move_no))) ' default 0.8 - changed 16/1/2010 'changed from 0.9 - 4/7/10
				av_think_time = game_time / Move_Control'
			end if
			if conv_clock = 1 and Move_Control = 0 then
				think_time = (time_left / 30)
				av_think_time = game_time / 80 ' assume average length of game
			end if
			if conv_clock = 0 then think_time = (0.04*(time_left + (40 * inc)))/1.3 'default 1.5
			if game_time <= 6000 or (tim = 1 and inc < 200) then post = 0
		ELSE
			O$ =  ucase(sWBCmd)
			call user_entry()
		END IF

	LOOP
	O$ = ucase(sWBCmd)

	END
END IF

fix_depth = 1 ' set fix depth flag for console mode

max_depth = 4 ' set default fixed depth search 4 ply for console mode  **

'**************************
' display start screen
'**************************
cls
Screen 21,1,1,1

Print "             *************************************************"
Print "             *     N O M E G A  -  c h e s s  e n g i n e    *"
Print "             *                                               *"
Print "             *         by  C h r i s  T a t h a m            *"
print "             *                                               *"
print "             *                                               *"
Print "             *             help - option list                *"
Print "             *                                               *"
Print "             *             (W)hite or (B)lack?               *"
Print "             *************************************************"

DO
	hitspace = getkey
LOOP UNTIL hitspace = 66 or hitspace = 98 or hitspace = 87 or hitspace = 119
cls

If hitspace = 87 or hitspace = 119 Then
	cmpclr = -1 
else 
	cmpclr = 1 'if press white then computer is black
EndIf

Sub mainmain(Side,flagout,Movefrom,MoveTo)
If flagout=100 Then GoTo mn2
main:

call display()

mn1:
call user_entry()

valid_move = user_move(Movefrom, MoveTo,side)

if valid_Move = false then goto mn1

if assessboard(side,best_score) = true then call ending()

Side = -Side

mn2:
call computer_move(side)

if assessboard(side,best_score) = true then call ending()

Side = -side

goto main
End
End Sub


If Side = cmpclr = -1 then  'Black
	call display()
	call mainmain(Side,100,Movefrom,MoveTo)
end if

'------------------------------------------------------------------------------

'**************************
' main control program
'**************************





mainmain(Side,0,Movefrom,MoveTo)

'/////////////////////////////////////////////////////////////////////////////
function user_entry()

	If WinboardMode = 1 then goto ue2 ' no need for text entry if using GUI!

	ue1:
	Input "move/option?"; O$

	IF LEFT$(O$,9) = "setboard " then call fen(O$)
	IF LEFT$(O$,5) = "perft" then
		Input"depth?"; depth
		t1 = timer
		perft = true
		call computer_move(side)
		t2 = timer
		accum = (t2-t1)
		Print
		print "Total node count = ";nodes
		Print "Time = "; accum;"s"
		Print "Average nodes/sec = "; int(nodes/accum)
		sleep
		perft = false
		mainmain(Side,0,Movefrom,MoveTo)
		Return 0
	end if
	IF O$ = "black" then
		side = black
		cmpclr = 1 'NOmega plays white
		call display()
	end if
	IF O$ = "white" then
		side = white
		cmpclr = -1 'NOmega plays black
		call display()
	end if
	If O$ = "go" then
		if side = white then cmpclr = 1
		if side = black then cmpclr = 1
		call computer_move(side)
		call display()
		if assessboard(side,best_score) = true then call ending()
		side = -side
	end if
	IF O$ = "listgame" then
		cls
		for j = 1 to MoveNo
			print j; " "; move_hist(j,1);"-";move_hist(j,2); "   "; move_hist(j,3);"-";move_hist(j,4)
		next
	end if
	IF O$ = "level" Then
		Input"depth?"; er
		max_depth = er
		fix_depth = 1
	end if
	IF O$ = "help" then
		call help()
		call display()
		goto ue1
	end if
	IF O$ = "save" then
		call SaveGame()
		call display()
		goto ue1
	end if
	IF O$ = "load" then
		call LoadGame()
		call display()
		goto ue1
	end if
	IF O$ = "end" then end

	If LEN(O$) <> 4  then goto ue1


	MoveFrom = ASC(O$) - 96 + 10 * (ASC(MID$(O$, 2, 1)) - 47)
	MoveTo = ASC(MID$(O$, 3, 1)) - 96 + 10 * (ASC(Mid$(O$, 4, 1)) - 47)


	ue2:

	' identify whether piece is to be promoted if so given winboard protocol
	' LEN must be 5 (eg a7a8q) then translate move into board co-ordinates
	IF WinboardMode = 1 and LEN(O$) = 5 then
		pr$ = Right$(O$,1) ' identify promotion piece
		L1$ = Left$(O$, 4)
		L1 = ASC(L1$) - 64
		M1$ = Mid$(O$, 2,3)
		M1 = ASC(M1$) - 48
		L2$ = Mid$(O$,3, 2)
		L2 = ASC(L2$) - 64
		M2$ = Mid$(O$,4,1)
		M2 = ASC(M2$) - 48
		F = 10 * M1 + 10 + L1
		T = 10 * M2 + 10 + L2
		Movefrom = F
		Moveto = T
	end if

	' translate move into board co-ordinates for non-promotion moves
	IF WinboardMode = 1 and LEN(O$) <> 5 then
		L1$ = RIGHT$(O$, 4)
		L1 = ASC(L1$) - 64
		M1$ = RIGHT$(O$, 3)
		M1 = ASC(M1$) - 48
		L2$ = RIGHT$(O$, 2)
		L2 = ASC(L2$) - 64
		M2$ = RIGHT$(O$, 1)
		M2 = ASC(M2$) - 48
		F = 10 * M1 + 10 + L1
		T = 10 * M2 + 10 + L2
		Movefrom = F
		Moveto = T
	end if


	IF L1 < 1 OR L1 > 8 OR M1 < 1 OR M1 > 8 THEN
		IF WinboardMode = 1 THEN
			goto ue3
		END IF
	END IF

	IF L2 < 1 OR L2 > 8 OR M2 < 1 OR M2 > 8 THEN
		IF WinboardMode = 1 THEN
			goto ue3
		END IF
	END IF


	IF WinBoardMode = 1 then call user_move(Movefrom,MoveTo,side)

	UE3:
end function


'///////////////////////////////////////////////////////////////////////////////
function user_move(Movefrom,Moveto,side)

	If side = white then MoveNo = MoveNo + 1


	If WinboardMode = 1 and ForceMode = 1 and ((side = white and cmpclr = 1) or (side = black and cmpclr = -1)) then conv_clock_move_no =  conv_clock_move_no + 1 ' increment move counter used for time management 'replaced from dev6 16/2/10


	depth = 1

	b_casflags(3,1)  = 0:b_casflags(3,2) = 0  ' need to reset search flags for ply 3 before generating moves to test legality

	w_casflags(3,1)  = 0:w_casflags(3,2) = 0  ' only need depth = 3 as genmove tests casflags at previous move - ie depth = 3

	if act_epsq <> -1 then epsqr(depth) = act_epsq  'set ep sqr if computer last moved pawn 2 squares

	CALL gen_move(side,depth,epsqr(),w_casflags(),b_casflags())

	valid_move = false


	for w = 1 to Pseu_Moves(depth)   'run through valid moves - if move entry is found then move is valid
		'  Print Move_List(depth,w,1);"-";Move_List(depth,w,2)
		if MoveFrom = Move_List(depth,w,1) AND MoveTo = Move_List(depth,w,2) then
			valid_move = True
			w = Pseu_Moves(depth)
		end if
	next w


	'handle special moves
	If side = black then goto um1

	If MoveFrom = 25 and MoveTo = 27 and B(25) = 7 and w_cas(1) = 0 THEN
		ps = 25              ' set attack sq to see if castle through check
		thru_check = attack(side,ps) 'test to see if sq is attacked
		ps = 26              'if not, then try next sq (don't need to try sq27 Kg1 - this will be picked up by 'check_root' below
		thru_check = attack(side,ps)
		if thru_check = true or (B(36) = -7 OR B(37) = -7 OR B(38) = -7) then valid_move = false ' if check found undo move
		if valid_move = true then
			B(28) = 0
			B(26) = 4           'move rook
			w_cas(1) = 1        'set white king castle flag
		end if
	END IF


	If MoveFrom = 25 and MoveTo = 23 and B(25) = 7 and w_cas(2) = 0 THEN
		ps = 25              ' set attack sq to see if castle through check
		thru_check = attack(side,ps) 'test to see if sq is attacked
		ps = 24              'if not, then try next sq (don't need to try sq27 Kg1 - this will be picked up by 'check_root' below
		thru_check = attack(side,ps)
		if thru_check = true or (B(22) = -7 OR B(32) = -7 OR B(33) = -7 OR B(34) = -7) then valid_move = false ' if check found undo move
		if valid_move = true then
			B(21) = 0
			B(24) = 4           'move rook
			w_cas(2) = 1        'set white king castle flag
		end if
	END IF
	'negate castling option if piece move is previously unmoved rook or king
	if MoveFrom = 21 and B(MoveFrom) = 4 THEN w_cas(2) = -1
	if MoveFrom = 28 and B(MoveFrom) = 4 THEN w_cas(1) = -1
	if MoveFrom = 25 and B(MoveFrom) = 7 and (w_cas(1) <> 1 or w_cas(2) <> 1) then
		w_cas(1) = -1
		w_cas(2) = -1
	end if


	if B(MoveFrom) = 1 and (MoveTo - MoveFrom = 20) Then
		act_epsq = MoveTo - 10 
	else 
		act_epsq = -1 ' set ep sqr if relevant
	EndIf

	goto um2

	um1:
	If MoveFrom = 95 and MoveTo = 97 and B(95) = -7 and b_cas(1) = 0 THEN
		ps = 95              ' set attack sq to see if castle through check
		thru_check = attack(side,ps) 'test to see if sq is attacked
		ps = 96              'if not, then try next sq (don't need to try sq27 Kg1 - this will be picked up by 'check_root' below
		thru_check = attack(side,ps)
		if thru_check = true or (B(86) = 7 OR B(87) = 7 OR B(88) = 7) then valid_move = false ' if check found undo move
		if valid_move = true then
			B(98) = 0
			B(96) = -4           'move rook
			b_cas(1) = 1        'set black king castle flag
		end if
	END IF


	If MoveFrom = 95 and MoveTo = 93 and B(95) = -7 and b_cas(2) = 0 THEN
		ps = 95              ' set attack sq to see if castle through check
		thru_check = attack(side,ps) 'test to see if sq is attacked
		ps = 94              'if not, then try next sq (don't need to try sq27 Kg1 - this will be picked up by 'check_root' below
		thru_check = attack(side,ps)
		if thru_check = true or (B(82) = 7 OR B(83) = 7 OR B(84) = 7) then valid_move = false ' if check found undo move
		if valid_move = true then
			B(91) = 0
			B(94) = -4           'move rook
			b_cas(2) = 1        'set white king castle flag
		end if
	END IF

	if MoveFrom = 91 and B(MoveFrom) = -4 THEN b_cas(2) = -1
	if MoveFrom = 98 and B(MoveFrom) = -4 THEN b_cas(1) = -1
	if MoveFrom = 95 and B(MoveFrom) = -7 and (b_cas(1) <> 1 or b_cas(2) <> 1) then
		b_cas(1) = -1
		b_cas(2) = -1
	end if

	if B(MoveFrom) = -1 and (MoveTo - MoveFrom = -20) Then
		act_epsq = MoveTo + 10 
	else 
		act_epsq = -1
	EndIf

	'make move....
	um2:
	temp_user_var = B(MoveTo)
	B(MoveTo) = B(MoveFrom)
	B(MoveFrom) = 0

	If B(MoveTo) = 7 THEN 
		wkloc = MoveTo 
	ElseIf B(MoveTo) = -7 Then
		bkloc = MoveTo 'keep record of king location
	EndIf

	Check_root = incheck(side)  ' test to see if move results in check

	If Check_root = True then valid_move = false           ' if so then illegal and take-back move

	If (Check_root = True and B(MoveTo) = 1 and MoveTo = epsqr(depth)) or (Check_root = True and B(MoveTo) = -1 and MoveTo = epsqr(depth)) then valid_move = true 'valid move if get out check by PxPep!

	if valid_move = false and WinboardMode = 0 then
		MoveNo = MoveNo - 1
		Print"invalid entry.."
		B(MoveFrom) = B(MoveTo)
		B(MoveTo) =  temp_user_var
		if B(MoveFrom) = 7 then wkloc = MoveFrom
		if B(MoveFrom) = -7 then bkloc = MoveFrom
		goto um3
	end if

	if valid_move = false and WinboardMode = 1 then
		MoveNo = MoveNo - 1
		B(MoveFrom) = B(MoveTo)
		B(MoveTo) =  temp_user_var
		if B(MoveFrom) = 7 then wkloc = MoveFrom
		if B(MoveFrom) = -7 then bkloc = MoveFrom
		SendCommand ("Illegal move: " + O$)
		exit function
	end if

	if B(MoveTo) = 1 or B(MoveTo) = -1 or temp_user_var <> 0 Then
		fifty_move = 0 
	Else
		fifty_move = fifty_move + 1
	EndIf

	If temp_user_var <> 0 then No_Pieces = No_Pieces - 1   'if piece is taken then reduce number of pieces on board

	' reduce material value depending on whihc piece has been taken...
	If abs(temp_user_var) = 6 then
		Mat_left = Mat_left - Queen_Value
		iF temp_user_var = 6 Then
			WQ = 0 
		Else
			BQ = 0
		EndIf
	END IF

	If abs(temp_user_var) = 4 then
		Mat_left = Mat_left - Rook_Value
		iF temp_user_var = 4 Then
			wr = wr - 1  
		ELSE 
			br = br - 1
		EndIf
	END IF

	If abs(temp_user_var) = 3 then Mat_left = Mat_left - Bishop_Value
	If abs(temp_user_var) = 2 then Mat_left = Mat_left - Knight_Value


	' ...in winboard mode
	If WinboardMode = 1 and B(MoveTo) = 1 and MoveTo > 90 then
		If pr$ = "Q" then B(MoveTo) = 6
		If pr$ = "R" then B(MoveTo) = 4
		If pr$ = "B" then B(MoveTo) = 3
		If pr$ = "N" then B(MoveTo) = 2
	end if

	If WinboardMode = 1 and B(MoveTo) = -1 and MoveTo < 29 then
		If pr$ = "Q" then B(MoveTo) = -6
		If pr$ = "R" then B(MoveTo) = -4
		If pr$ = "B" then B(MoveTo) = -3
		If pr$ = "N" then B(MoveTo) = -2
	end if


	' ...in console mode
	If B(MoveTo) = 1 and MoveTo > 90 then                '/
		Input "Promotion (Q/R/B/N)?"; promotion$            '/
		If promotion$ = "Q" then B(MoveTo) = 6      '/
		If promotion$ = "R" then B(MoveTo) = 4     '/
		If promotion$ = "B" then B(MoveTo) = 3     '/
		If promotion$ = "N" then B(MoveTo) = 2      '/
	end if

	If B(MoveTo) = -1 and MoveTo < 29 then                '/
		Input "Promotion (Q/R/B/N)?"; promotion$            '/
		If promotion$ = "Q" then B(MoveTo) = -6      '/
		If promotion$ = "R" then B(MoveTo) = -4      '/
		If promotion$ = "B" then B(MoveTo) = -3      '/
		If promotion$ = "N" then B(MoveTo) = -2      '/
	end if

	If B(MoveTo) = 1 and MoveTo = epsqr(depth) then B(MoveTo-10) = 0  ' 'remove black pawn if white move is pxp ep

	If B(MoveTo) = -1 and MoveTo = epsqr(depth) then B(MoveTo+10) = 0 'remove white pawn if black move is pxp ep



	if side = white then                                   ' update move history with current move
		move_hist(MoveNo,1) = MoveFrom
		move_hist(MoveNo,2) = MoveTo
	elseif side = black then
		move_hist(MoveNo,3) = MoveFrom
		move_hist(MoveNo,4) = MoveTo
	end if

	STM = computer

	if winboardmode = 0 then call display()

	If winboardmode = 1 and ForceMode = 0 then
		if assessboard(side,best_score) = true then exit function
		side = -side
		if MoveNo > 8 then  ' max book length is 8 moves
			call computer_move(side)
		elseif open_book() = false then 'make computer move if no book move is found
			call computer_move(side)
		end if
		if assessboard(side,best_score) = true then exit function
		side = -side
	end if

	If winboardmode = 1 and ForceMode = 1 then side = -side


	um3:
	return valid_move

END FUNCTION



'///////////////////////////////////////////////////////////////////////////////
function computer_move(side)

	if winboardMode = 0 and perft = false and open_book() = true then exit function

	Dim AS double ply_end_time , ply_start_time, elp_time, test_time, accum1

	dim root_sort(70) AS single
	dim r1 AS single

	total_nodes = 0


	if perft = true then
		it_depth = 1
		goto cm
	end if


	If side = white then MoveNo = MoveNo + 1


	if forcemode = 1 then Return 0



	if fix_depth = 0 then ply_start_time = timer

	start_time = int(ply_start_time)

	timed_out = 0 ' flag to cut search if used too much time

	If endgame = 1 and fix_depth = 0 then   ' in K+Q/R v K limit search to 5 ply unless opponent king is on board edge
		Weg_condition1 = (No_pieces = 3 and (wr = 1 or WQ = 1))
		Beg_condition1 = (No_pieces = 3 and (br = 1 or BQ = 1))
		if side = black and Beg_condition1 and K_r_end_PST(wkloc) < 45 Then
			max_depth = 5 
		elseif side = black Then
			max_depth = 15
		EndIf
		if side = white and Weg_condition1 and K_r_end_PST(bkloc) < 45 Then
			max_depth = 5 
		elseif side = white Then
			max_depth = 15
		EndIf
	end if



	for it_depth = 1 to max_depth

		prom_depth = 0 ' reset variable to store depth of promotion


		prom_last_ply = 0

		depth = it_depth

		search_depth = depth

		cm:
		best_score = -10000


		for v = 1 to 2
			if w_cas(v) <> 0 then w_casflags(depth,v) = w_cas(v) ' reset white castle flags (eg from fen)
			if b_cas(v) <> 0 then b_casflags(depth,v) = b_cas(v)' reset black castle flags
		next v

		epsqr(depth) = act_epsq 'update epsqr in search with results of last move

		Search_Condition1 = (perft = false and it_depth = 1)


		If (Search_Condition1 or perft = true) Then
			call gen_move(side,depth,epsqr(),w_casflags(),b_casflags()) 
		Else
			Pseu_Moves(depth) = root ' generate moves at root
		EndIf

		root = 0
		nodes = 0                  ' re-set node counter

		IM = 0   ' insufficient material flag


		for w = 1 to Pseu_Moves(depth) ' loop through root moves

			thru_check = false ' added 18/2/10 - flag is needed to prevent castle when in check at root

			Check_Root = false  '14/12 - need this line else if in check at root only best move at ply 1 is chosen


			fmove(depth) = fifty_move

			alpha = -9999
			beta = 9999


			prom_piece = 0   'reset promotion flag (re-set for each root move therefore will pick up each different promotion piece)

			for t = 1 to depth

				wprom(t) = 0:bprom(t) = 0  ' rest w/b promotion flags

				for v = 1 to 2
					w_casflags(depth,v) = w_cas(v):b_casflags(depth,v) = b_cas(v)   ' reset castle flags to original values
				next v

				if act_epsq <> -1 and t = depth Then
					epsqr(t) = act_epsq 
				Else
					epsqr(t) = -1  'if last opponent move has generated epsq then set this for search else reset ep_square
				EndIf

			next t


			nodes_root_move = nodes    ' var to calc nodes per individual root move


			' EP at root

			' set ep field for root move - if white
			IF (Move_List(depth,w,2) - Move_List(depth,w,1) = 20) and B(Move_List(depth,w,1)) = 1 and (B(Move_List(depth,w,2)-1) = -1 or B(Move_List(depth,w,2)+1) = -1) then
				epsqr(depth-1)= Move_List(depth,w,1) + 10 'epsqr will be set for ply 2
			end if


			' set ep field for root move - if black
			If (Move_List(depth,w,2) - Move_List(depth,w,1) = -20) and B(Move_List(depth,w,1)) = -1 and (B(Move_List(depth,w,2)-1) = 1 or B(Move_List(depth,w,2)+1) = 1) then
				epsqr(depth-1)= Move_List(depth,w,1) - 10 'epsqr will be set for ply 2
			end if



			temp_root_move_val = B(Move_List(depth,w,2))  'hold contents of root move move to sq
			B(Move_List(depth,w,2)) = B(Move_List(depth,w,1)) ' make move at root
			B(Move_List(depth,w,1)) = 0                       ' empty move from sq


			cap_sq = Move_List(depth,w,2)   ' hold root capture sq for swap-off
			temp_val1(1) = temp_root_move_val ' hold root capture piece for swap-off
			init_swp_val = B(Move_List(depth,w,2))

			' code below reduces material and piece count remaining if piece has been captured at root

			If temp_root_move_val <> 0 then No_Pieces = No_Pieces - 1

			If abs(temp_root_move_val) = 6 then
				Mat_left = Mat_left - Queen_Value
				If temp_root_move_val = 6 Then
					WQ = 0 
				Else
					BQ = 0
				EndIf
			END IF

			If abs(temp_root_move_val) = 4 then Mat_left = Mat_left - Rook_Value
			If abs(temp_root_move_val) = 3 then Mat_left = Mat_left - Bishop_Value
			If abs(temp_root_move_val) = 2 then Mat_left = Mat_left - Knight_Value
			If abs(temp_root_move_val) = 1 then
				Knight_Value = Knight_Value - 1 'Kn loses value as number of pawns reduce
				Rook_Value = Rook_Value + 1     'Rk value increases as pawns reduce
			end if

			IF temp_root_move_val <> 0 OR B(Move_List(depth,w,2)) = 1 OR B(Move_List(depth,w,2)) = -1 THEN
				fmove(depth) = 0
			else
				fmove(depth) = fifty_move + 1
			end if

			If Move_List(depth,w,2) = act_epsq and B(Move_List(depth,w,2)) = -1 then B(Move_List(depth,w,2)+10) = 0 ' take off white pawn after black pxp ep
			If Move_List(depth,w,2) = act_epsq and B(Move_List(depth,w,2)) = 1 then B(Move_List(depth,w,2)-10) = 0 ' take off pawn after white pxp ep


			' check for castling at root

			if side = black then goto cm1

			if B(Move_List(depth,w,2)) = 7 then wkloc = Move_List(depth,w,2)

			If Move_List(depth,w,1) = 25 and Move_List(depth,w,2) = 27 and B(27) = 7 THEN ' test for white O-O
				ps = 25              ' set attack sq to see if castle through check
				thru_check = attack(side,ps) 'test to see if sq is attacked
				if thru_check = false then
					ps = 26              'if not, then try next sq (don't need to try sq27 Kg1 - this will be picked up by 'check_root' below
					thru_check = attack(side,ps)
				end if
				if thru_check = true then goto cm3 ' if check found undo move
				IF B(36) = -7 OR B(37) = -7 OR B(38) = -7 THEN GOTO cm3 ' can't castle if adjacent to king!
				B(28) = 0: B(26) = 4 ' move rook
				w_casflags(depth,1) = 1    ' set white king castle flag
			end if
			'

			If Move_List(depth,w,1) = 25 and Move_List(depth,w,2) = 23 and B(23) = 7 THEN  ' test for white O-O-O
				ps = 25
				thru_check = attack(side,ps)
				if thru_check = false then
					ps = 24
					thru_check = attack(side,ps)
				end if
				if thru_check = true then goto cm3
				IF B(32) = -7 OR B(33) = -7 OR B(34) = -7 THEN GOTO cm3 ' can't castle if adjacent to king!
				B(21) = 0: B(24) = 4
				w_casflags(depth,2) = 1   ' set white queen castle flag
			end if


			If w_casflags(depth,1) <> 1 and (B(25) <> 7 or B(28) <> 4) THEN w_casflags(depth,1) = -1
			If w_casflags(depth,2) <> 1 and (B(25) <> 7 or B(21) <> 4) THEN w_casflags(depth,2) = -1
			''

			if Move_List(depth,w,2) > 90 and B(Move_List(depth,w,2)) = 1 then wprom(depth) = 1    'set promotion flag

			if Move_List(depth,w,2) > 90 and B(Move_List(depth,w,2)) = 1 and Move_List(depth,w,3) = 6 then B(Move_List(depth,w,2)) = 6
			if Move_List(depth,w,2) > 90 and B(Move_List(depth,w,2)) = 1 and Move_List(depth,w,3) = 4 then B(Move_List(depth,w,2)) = 4
			if Move_List(depth,w,2) > 90 and B(Move_List(depth,w,2)) = 1 and Move_List(depth,w,3) = 3 then B(Move_List(depth,w,2)) = 3
			if Move_List(depth,w,2) > 90 and B(Move_List(depth,w,2)) = 1 and Move_List(depth,w,3) = 2 then B(Move_List(depth,w,2)) = 2

			goto cm2


			cm1:

			if B(Move_List(depth,w,2)) = -7 then bkloc = Move_List(depth,w,2)

			If Move_List(depth,w,1) = 95 and Move_List(depth,w,2) = 97 and B(97) = -7 THEN   ' test for black O-O
				ps = 95
				thru_check = attack(side,ps)
				if thru_check = false then
					ps = 96
					thru_check = attack(side,ps)
				end if
				if thru_check = true then goto cm3
				B(98) = 0: B(96) = -4  ' need to make the move after found to be a valid move!
				b_casflags(depth,1) = 1
			end if


			If Move_List(depth,w,1) = 95 and Move_List(depth,w,2) = 93 and B(93) = -7 THEN   ' test for black O-O-O
				ps = 95
				thru_check = attack(side,ps)
				if thru_check = false then
					ps = 94
					thru_check = attack(side,ps)
				end if
				if thru_check = true then goto cm3
				B(91) = 0: B(94) = -4
				b_casflags(depth,2) = 1
			end if

			If b_casflags(depth,1) <> 1 and (B(95) <> -7 or B(98) <> -4) THEN b_casflags(depth,1) = -1
			If b_casflags(depth,2) <> 1 and (B(95) <> -7 or B(91) <> -4) THEN b_casflags(depth,2) = -1


			if Move_List(depth,w,2) < 29 and B(Move_List(depth,w,2)) = -1 then bprom(depth) = 1   'set promotion flag


			if Move_List(depth,w,2) < 29 and B(Move_List(depth,w,2)) = -1 and Move_List(depth,w,3) = -6 then B(Move_List(depth,w,2)) = -6
			if Move_List(depth,w,2) < 29 and B(Move_List(depth,w,2)) = -1 and Move_List(depth,w,3) = -4 then B(Move_List(depth,w,2)) = -4
			if Move_List(depth,w,2) < 29 and B(Move_List(depth,w,2)) = -1 and Move_List(depth,w,3) = -3 then B(Move_List(depth,w,2)) = -3
			if Move_List(depth,w,2) < 29 and B(Move_List(depth,w,2)) = -1 and Move_List(depth,w,3) = -2 then B(Move_List(depth,w,2)) = -2

			'cm2:
			'Print "make root move.."
			'   Print
			'
			'FOR X = 9 TO 2 STEP -1
			'    FOR Yl = 1 TO 8
			'        Print B(X*10+Yl);
			'
			'    NEXT Yl
			'    print
			'NEXT X
			'Print
			'sleep


			cm2:

			if it_depth = 1 then Check_root = incheck(side)  ' test to see if move results in check

			If it_depth = 1 and Check_root = True then goto cm2a           ' if so then illegal and take-back move (jump to cm2a to enable reverse of pawn prom if in check - 7/11/08


			'
			if fmove(depth) = 100 then  'score = if 50 move rule is tripped
				score = 0
				goto cm2x
			end if

			If (ENDGAME = 1 OR Mat_Left < 2426) Then
				ENDGAME = 1 
			ELSE 
				ENDGAME  = 0 ' condition to determine if endgame eval is engaged
			EndIf
			'
			'

			score = -ab_search(-side, depth-1,alpha, beta, epsqr(),w_casflags(),b_casflags(),fmove())

			If (No_Pieces = 3 and (Bbp + Wbp + Bkn + Wkn = 1)) OR (No_Pieces = 4 and (Bbp + Bkn = 1 and Wbp + Wkn = 1))  then score = 0
			If  No_Pieces = 2  then score = 0

			iF search_depth > 4 and score > best_score and Check_root = false then ' test for move repitition
				check_rep = rep_check(side)
				If check_rep = True then score = 0
			end if


			cm2x:

			root = root + 1

			If it_depth = 1 then orig_root = root


			root_sort(root) = score

			Move_list_root(depth,root,1) = Move_List(depth,w,1)
			Move_list_root(depth,root,2) = Move_List(depth,w,2)
			Move_list_root(depth,root,3) = Move_List(depth,w,3)


			IF temp_root_move_val <> 0 OR B(Move_List(depth,w,2)) = 1 OR B(Move_List(depth,w,2)) = -1 THEN
				fmove(depth) = fifty_move
			ELSE 
				fmove(depth) = fmove(depth) - 1
			end if

			If perft = true then print Move_List(depth,w,1);"-"; Move_List(depth,w,2); " ";nodes - nodes_root_move ; " nodes"
			' Print "Depth = ";depth; " ";Move_List(depth,w,1);"-"; Move_List(depth,w,2); " ";nodes - nodes_root_move ; " nodes"; " "; "score = ";score'; " bkloc = ";bkloc

			'sleep 60000

			cm2a:
			if Move_List(depth,w,2) > 90 and B(Move_List(depth,w,2)) = 6 and Move_List(depth,w,3) = 6 and wprom(depth) = 1 then B(Move_List(depth,w,2)) = 1
			if Move_List(depth,w,2) > 90 and B(Move_List(depth,w,2)) = 4 and Move_List(depth,w,3) = 4 and wprom(depth) = 1 then B(Move_List(depth,w,2)) = 1
			if Move_List(depth,w,2) > 90 and B(Move_List(depth,w,2)) = 3 and Move_List(depth,w,3) = 3 and wprom(depth) = 1 then
				B(Move_List(depth,w,2)) = 1
				Wbp = Wbp - 1   ' see explanation in make move function - don't need to ++ piece no in make move as eval counts number of pieces by type
			end if
			if Move_List(depth,w,2) > 90 and B(Move_List(depth,w,2)) = 2 and Move_List(depth,w,3) = 2 and wprom(depth) = 1 then
				B(Move_List(depth,w,2)) = 1
				Wkn = Wkn - 1
			end if


			if Move_List(depth,w,2) < 29 and B(Move_List(depth,w,2)) = -6 and Move_List(depth,w,3) = -6 and bprom(depth) = 1 then B(Move_List(depth,w,2)) = -1
			if Move_List(depth,w,2) < 29 and B(Move_List(depth,w,2)) = -4 and Move_List(depth,w,3) = -4 and bprom(depth) = 1 then B(Move_List(depth,w,2)) = -1
			if Move_List(depth,w,2) < 29 and B(Move_List(depth,w,2)) = -3 and Move_List(depth,w,3) = -3 and bprom(depth) = 1 then
				B(Move_List(depth,w,2)) = -1
				Bbp = Bbp - 1
			end if
			if Move_List(depth,w,2) < 29 and B(Move_List(depth,w,2)) = -2 and Move_List(depth,w,3) = -2 and bprom(depth) = 1 then
				B(Move_List(depth,w,2)) = -1
				Bkn = Bkn - 1
			end if


			' unmake root move

			cm3:
			B(Move_List(depth,w,1)) = B(Move_List(depth,w,2)) ' unmake move at root
			B(Move_List(depth,w,2)) = temp_root_move_val      'replace original contents of sq


			If temp_root_move_val <> 0 then No_Pieces = No_Pieces + 1

			If abs(temp_root_move_val) = 6 then
				Mat_left = Mat_left + Queen_Value
				If temp_root_move_val = 6 Then
					WQ = 1 
				Else
					BQ = 1
				EndIf
			END IF

			If abs(temp_root_move_val) = 4 then Mat_left = Mat_left + Rook_Value
			If abs(temp_root_move_val) = 3 then Mat_left = Mat_left + Bishop_Value
			If abs(temp_root_move_val) = 2 then Mat_left = Mat_left + Knight_Value
			If abs(temp_root_move_val) = 1 then
				Knight_Value = Knight_Value + 1
				Rook_Value = Rook_Value - 1
			end if

			If Move_List(depth,w,2) = act_epsq and B(Move_List(depth,w,1)) = -1 then B(Move_List(depth,w,2)+10) = 1 ' replace white pawn after undo root move of black pxp ep

			If Move_List(depth,w,2) = act_epsq and B(Move_List(depth,w,1)) = 1 then B(Move_List(depth,w,2)-10) = -1 ' replace black pawn after undo root move of white pxp ep


			if B(Move_List(depth,w,1)) = 7 then wkloc = Move_List(depth,w,1)
			if B(Move_List(depth,w,1)) = -7 then bkloc = Move_List(depth,w,1)

			if thru_check = true then goto cm3a

			If side = white and w_casflags(depth,1) = 1 AND w_cas(1) = 0 then  ' if K-side castled then unmake rook move at root
				B(26) = 0: B(28) = 4
				w_casflags(depth,1) = 0 ' reset kingside castle flag
			elseif side = black and b_casflags(depth,1) = 1 AND b_cas(1) = 0 then  'corrected 24/3/09 thanks Leo!
				B(96) = 0: B(98) = -4
				b_casflags(depth,1) = 0
			END IF

			'
			If side = white and w_casflags(depth,2) = 1 AND w_cas(2) = 0 then 'if Q-side castled then unmake rook move at root
				B(24) = 0: B(21) = 4
				w_casflags(depth,2) = 0                      ' reset queenside castle flag
			elseif side = black and b_casflags(depth,2) = 1 AND b_cas(2) = 0 then
				B(94) = 0: B(91) = -4
				b_casflags(depth,2) = 0
			END IF

			if perft = true then goto cm4
			'
			'            Print "unmake root move.."
			'   Print
			'
			'FOR X = 9 TO 2 STEP -1
			'    FOR Yl = 1 TO 8
			'        Print B(X*10+Yl);
			'
			'    NEXT Yl
			'    print
			'NEXT X
			'Print
			'sleep


			if timed_out = 1 then    ' if run out of time then finish search
				w  = Pseu_Moves(depth)
				it_depth = max_depth
				goto it6
			end if



			If score > best_score and Check_root = false then                 ' if new best score then
				best_score = score ' set new best-score
				B_M_From = Move_List(depth,w,1)
				B_M_To = Move_List(depth,w,2)
				Pe = B(Move_List(depth,w,1))
				If prom_last_ply = 1 then prom_last_ply = 0 'reset promotion flag if promotion is no longer best move in current ply
				if side = white and wprom(depth) = 1 then
					prom_last_ply = 1
					Pe = Move_List(depth,w,3) 'if promoted piece then update sqr with new piece
					Move_List(depth,w,3) = 0  ' reset prom piece else 2nd prom with Q on back rank turns Q back to P! 14/11/08
				end if
				if side = black and bprom(depth) = 1 then
					prom_last_ply = 1
					Pe = Move_List(depth,w,3) 'if promoted piece then update sqr with new piece
					Move_List(depth,w,3) = 0  ' reset prom piece else 2nd prom with Q on back rank turns Q back to P! 14/11/08
				end if
				If it_depth > 3 then  'for depth > 3 then display pv etc
					elp_time = timer
					accum1 = (elp_time-ply_start_time)
					j11$ = STR(Move_List(depth,w,1))
					k11$ = STR(Move_List(depth,w,2))
					j21$ = Left$(j11$,1)
					j31$ = Right$(j11$,1)
					k21$ = Left$(k11$,1)
					k31$ = Right$(k11$,1)
					BMFROM$ = (CHR(ASC(j31$) + 48)) + (CHR(ASC(j21$) - 1))
					BMTO$ = (CHR(ASC(k31$) + 48)) + (CHR(ASC(k21$) - 1))
					if post = 1 then print it_depth;" ";best_score;" ";cint((elp_time-ply_start_time) * 100);" ";total_nodes + nodes; " ";BMFROM$; BMTO$
				end if
			end if



			' above 3 ply following lines attempt to implement some crude reductions in root moves searched at deeper ply based on score
			if it_depth = 4 and score - best_score < -350 then root = root - 1
			if it_depth = 5 and score - best_score < -200 then root = root - 1 '225

			if it_depth = 6 and score - best_score < -175 then root = root - 1'200

			if it_depth > 6 and score - best_score < -150 then root = root - 1 '175


			If best_score > 9980  then      ' if mate is found then no need to search further!
				w = Pseu_Moves(depth)
				it_depth = max_depth
			end if

			cm3a:

			if fix_depth = 1 then goto cm4

			test_time = timer

			' if used more than think time for move then stop searching unless almost at the end of current iteration
			' test here rather than at start of move so that after make move.


			if conv_clock = 1 and ((test_time - ply_start_time) * 100) > 2.5 * av_think_time then  'ply_end_time? = original -  2.2 26/10
				w  = Pseu_Moves(depth)
				it_depth = max_depth
				goto it6
			end if

			'
			if (((test_time - ply_start_time) * 100)  > = (0.95 * think_time))  then '0.9  26/10/09 'changed to 0.95 - 4/07/10
				w  = Pseu_Moves(depth)
				it_depth = max_depth
				goto it6
			end if
			' next line added dev3 - 14/1/2010
			if (((test_time - ply_start_time) * 100)  > = (0.35 * time_left))  then '0.9  26/10/09
				w  = Pseu_Moves(depth)
				it_depth = max_depth
				goto it6
			end if


			cm4:


		Next w


		if perft = true then goto it7

		If (it_depth = 1 and root = 1) or best_score < -9993 then it_depth = max_depth ' if only 1 legal move, or close to mate then no point searching further!



		if it_depth = max_depth then goto it6


		DO                                            ' bubble sort moves according to score ready for next ply
			unsorted = 0
			'
			for i = 1 to root-1
				'
				IF root_sort(i) < root_sort(i+1) THEN
					r1 = root_sort(i)
					root_sort(i) = root_sort(i+1)
					root_sort(i+1) = r1
					Move_list_temp(depth,i,1) = Move_list_root(depth,i,1)
					Move_list_temp(depth,i,2) = Move_list_root(depth,i,2)
					Move_list_temp(depth,i,3) = Move_list_root(depth,i,3)
					Move_list_root(depth,i,1) = Move_list_root(depth,i+1,1)
					Move_list_root(depth,i,2) = Move_list_root(depth,i+1,2)
					Move_list_root(depth,i,3) = Move_list_root(depth,i+1,3)
					Move_list_root(depth,i+1,1) = Move_list_temp(depth,i,1)
					Move_list_root(depth,i+1,2) = Move_list_temp(depth,i,2)
					Move_list_root(depth,i+1,3) = Move_list_temp(depth,i,3)
					unsorted = 1
				END IF

			next i


		LOOP WHILE unsorted

		it3:

		FOR i = 1 TO root
			Move_list(depth+1,i,1) = Move_list_root(depth,i,1)
			Move_list(depth+1,i,2) = Move_list_root(depth,i,2)
			Move_list(depth+1,i,3) = Move_list_root(depth,i,3)
		next

		if depth = 1 and root_sort(1) - root_sort(2) > 250 then
			B_M_To_easy_move =  B_M_To
			B_M_From_easy_move =  B_M_From
		end if

		'If depth = 1 then
		'    print " at d=1 rs1 = "; root_sort(1) ;  " rs2 = "; root_sort(2)
		'    Print B_M_From_easy_move; B_M_To_easy_move
		'    end if
		'

		'if depth = 4 then Print  "at d=4 "; "rs1 = "; root_sort(1) ;  " rs2 = "; root_sort(2)
		if depth = 4 and root_sort(1) - root_sort(2) > 250 and Move_list(depth+1,1,1) = B_M_From_easy_move and Move_list(depth+1,1,2) = B_M_To_easy_move then it_depth = max_depth


		if fix_depth = 0 then ply_end_time = timer
		if it_depth < 6 and think_time < ((ply_end_time - ply_start_time) * 150) then it_depth = max_depth 'default = 400 (26/1/09) ' 275 26/10/09  '200 21/11/09 '150 (5/7/10)
		if it_depth >= 6 and think_time < ((ply_end_time - ply_start_time) * 225) then it_depth = max_depth 'default = 400 (26/1/09) ' 275 26/10/09  '200 21/11/09 '150 (5/7/10)

		if conv_clock = 1 and (ply_end_time - ply_start_time) > 2.5 * av_think_time then it_depth = max_depth '2.2 (26/10/09


		'B_M_To_last_ply =  B_M_To:B_M_From_last_ply =  B_M_From
		'last_ply_piece = Pe

		it6:
		'Print "think = ";think_time; "plye-plys = ";(ply_end_time - ply_start_time) * 100
		'Print "moved in (s) = ";(ply_end_time - ply_start_time) * 100

		it7:
		total_nodes = total_nodes + nodes




	next it_depth


	if perft = true then goto cm7a


	Prom_Piece$ = ""

	If NOT prom_last_ply = 0 then                                  'identify promotion piece for winboard
		IF abs(Pe) = 6 then Prom_Piece$ = "Q"
		if abs(Pe) = 4 then Prom_Piece$ = "R"
		if abs(Pe) = 3 then Prom_Piece$ = "B"
		if abs(Pe) = 2 then Prom_Piece$ = "N"
	end if


	If B(B_M_To) <> 0 then No_Pieces = No_Pieces - 1   'if piece is taken then reduce number of pieces on board


	If B(B_M_To)  = 2 then Wkn = Wkn - 1
	if B(B_M_To)  = 3 then WBp = WBp - 1
	if B(B_M_To)  = -2 then Bkn = Bkn - 1
	if B(B_M_To)  = -3 then Bkn = Bkn - 1

	IF B(B_M_To) <> 0 OR B(B_M_From) = 1 OR B(B_M_From) = -1 Then
		fifty_move = 0 
	else 
		fifty_move = fifty_move + 1
	EndIf

	If abs(B(B_M_To)) = 6 then
		Mat_left = Mat_left - Queen_Value
		If B(B_M_To) = 6 Then
			WQ = 0 
		ELSE 
			BQ = 0
		EndIf
	END IF

	If abs(B(B_M_To)) = 4 then
		Mat_left = Mat_left - Rook_Value
		If B(B_M_To) = 4 Then
			wr = wr - 1 
		Else
			br = br - 1
		EndIf
	END IF

	If abs(B(B_M_To)) = 3 then Mat_left = Mat_left - Bishop_Value
	If abs(B(B_M_To)) = 2 then Mat_left = Mat_left - Knight_Value
	If abs(B(B_M_To)) = 1 then
		Knight_Value = Knight_Value - 1
		Rook_Value = Rook_Value + 1
	end if

	B(B_M_From) = 0 : B(B_M_To) = Pe   'make computer move


	if side = white then                                   ' update move history with current move
		move_hist(MoveNo,1) = B_M_From
		move_hist(MoveNo,2) = B_M_To
	elseif side = black then
		move_hist(MoveNo,3) = B_M_From
		move_hist(MoveNo,4) = B_M_To
	end if


	' promotion piece is updated in best move routine - remember if problems later that it perhaps should be updated after the move is made? (cht 29/10/08)

	j1$ = STR(B_M_From)
	k1$ = STR(B_M_To)

	j2$ = left$(j1$,1)
	j3$ = right$(j1$,1)

	k2$ = left$(k1$,1)
	k3$ = right$(k1$,1)


	CompMoveFrom$ = (CHR(ASC(j3$) + 48)) + (CHR(ASC(j2$) - 1))
	CompMoveTo$ = (CHR(ASC(k3$) + 48)) + (CHR(ASC(k2$) - 1))


	cm4a:


	if side = black then goto cm5


	if B(B_M_To) = 7 then wkloc = B_M_To   ' update the relevant king position

	If B(B_M_To) = 1 and B_M_To = act_epsq then B(B_M_To - 10) = 0   'take off black pawn if white move is pxp ep capture

	If  B(B_M_To) = 1 and (B_M_To - B_M_From = 20) Then
		act_epsq = B_M_To - 10 
	Else
		act_epsq = -1  'set ep-square for next move (if next move is black)
	EndIf

	if B_M_From = 21 and B(B_M_To) = 4 THEN w_cas(2) = -1

	if B_M_From = 28 and B(B_M_To) = 4 THEN w_cas(1) = -1

	if B_M_From = 25 and B_M_To = 27 and B(B_M_To) = 7 then
		B(28) = 0
		B(26) = 4
		w_cas(1) = 1
		w_cas(2) = -1 'added 16/1/2010 - Leo castle bug
	elseif B_M_From = 25 and B_M_To = 23 and B(B_M_To) = 7 then
		B(21) = 0
		B(24) = 4
		w_cas(2) = 1
		w_cas(1) = -1 'added 16/1/2010 - Leo castle bug
	end if

	if B_M_From = 25 and B(B_M_To) = 7 and (w_cas(1) <> 1 or w_cas(2) <> 1) then
		w_cas(1) = -1
		w_cas(2) = -1
	end if

	goto cm7


	cm5:

	' black moves

	if B(B_M_To) = -7 then bkloc = B_M_To  ' update the relevant king position

	If B(B_M_To) = -1 and B_M_To = act_epsq then B(B_M_To + 10) = 0   'take off white pawn if black move is pxp ep capture

	If B(B_M_To) = -1 and (B_M_To - B_M_From = -20) Then
		act_epsq = B_M_To + 10 
	Else
		act_epsq = -1 'set ep-square for next move (if next move is white)
	EndIf



	if B_M_From = 91 and B(B_M_To) = -4 THEN b_cas(2) = -1

	if B_M_From = 98 and B(B_M_To) = -4 THEN b_cas(1) = -1


	if B_M_From = 95 and B_M_To = 97 and B(B_M_To) = -7 then
		B(98) = 0
		B(96) = -4
		b_cas(1) = 1
		b_cas(2) = -1 'added 16/1/2010 - Leo castle bug
	elseif B_M_From = 95 and B_M_To = 93 and B(B_M_To) = -7 then
		B(91) = 0
		B(94) = -4
		b_cas(2) = 1
		b_cas(1) = -1 'added 16/1/2010 - Leo castle bug
	end if

	if B_M_From = 95 and B(B_M_To) = -7 and (b_cas(1) <> 1 or b_cas(2) <> 1) then
		b_cas(1) = -1
		b_cas(2) = -1
	end if


	if perft = true then goto cm7a


	cm7:
	'  Print "Total moves at root = ";orig_root'root
	'  print "Total node count = ";total_node



	if winboardmode = 0 then display_node = total_nodes
	'    sleep
	'    end if
	'
	If (No_Pieces = 3 and (Bbp + Wbp + Bkn + Wkn = 1)) then IM = 1 ' set insufficient material flag if appropriate


	STM = Opponent


	IF WinboardMode = 1 and root <> 0 THEN
		conv_clock_move_no =  conv_clock_move_no + 1
		SendCommand ("move " + lcase(CompMoveFrom$ + CompMoveTo$ + Prom_Piece$))
	END IF

	'
	cm7a:
	return nodes

	c8:
end function

'////////////////////////////////////////////////////////////////////////////
function ab_search(side,depth,alpha AS single, beta  AS single, epsqr(),w_casflags(),b_casflags(),fmove()) AS SINGLE

	if perft = true then goto ab

	'if fmove(depth+1) = 100 then   'insearch 50  move rule test - removed 21/2/2010 (c5% speed up in total)
	'    nodes = nodes + 1
	'    depth = 0
	'    return 0
	'    end if
	'
	'

	if depth = 0 and temp_val1(1) <> 0 then  ' if move @ horizon is capture then engage swap-off routine
		stand_pat = evaluate(side)
		Vo = init_swp_val
		swap_value = Qs(Vo,side)
		'If winboardmode = 0 and ((cmpclr = 1 and side = black) or (cmpclr = -1 and side = white)) and swap_value < 0 then swap_value = 0
		'If winboardmode = 1 and ((cmpclr = 1 and side = white) or (cmpclr = -1 and side = black)) and swap_value < 0 then swap_value = 0 'orig line
		if swap_value < 0 then swap_value = 0
		return stand_pat + swap_value
	END IF

	if depth = 0 and (wprom(1) = 1 or bprom(1) = 1) then 'if horizon move is promotion, extend to see if pawn is captured
		stand_pat = evaluate(side)
		Vo = init_swp_val
		iF wprom(1) = 1 then Vo = 6
		if bprom(1) = 1 then Vo = -6
		swap_value = Qs(Vo,side)
		If winboardmode = 0 and ((cmpclr = 1 and side = black) or (cmpclr = -1 and side = white)) and swap_value < 0 then swap_value = 0
		If winboardmode = 1 and ((cmpclr = 1 and side = white) or (cmpclr = -1 and side = black)) and swap_value < 0 then swap_value = 0
		'if swap_value < 0 then swap_value = 0
		return stand_pat + swap_value
	END IF


	ab:
	if depth = 0 then
		nodes = nodes + 1
		if perft = false Then
			return evaluate(side) 
		else 
			return nodes
		EndIf
	end if


	if search_depth > 5 and (orig_root < 5 or (Move_Control - conv_clock_move_no) < 4) then 'sd criteria added to make sure move from last ply is available to play (21/6/10)
		break = timer
		if (((break - start_time) * 100) > think_time) or (((break - start_time) * 100)  > = (0.4 * time_left)) then '(changed from 0.3  - 4/7/10)
			timed_out = 1
			exit function 'return 0'evaluate(side)
		end if
	end if


	Call gen_move(side,depth,epsqr(),w_casflags(),b_casflags())

	xg = 0 ' counter to test for legal moves

	'
	For y = 1 to Pseu_Moves(Depth)

		'

		Call make_move(side,depth,Pseu_Moves(),y,epsqr(),w_casflags(),b_casflags(),wprom(),bprom(),fmove())


		Check = incheck(side)
		'
		If Check = True then goto p1
		'


		if side = black then goto pw1

		IF w_casflags(depth,1) = 1 and w_casflags(depth+2,1) = 0 THEN  'if last move is O-O test this is not thru check (nb but what if castled more than depth+2?? because in make move we are setting depth = depth+2???
			ps = 25
			thru_check = attack(side,ps)
			if thru_check = false then
				ps = 26
				thru_check = attack(side,ps)
			end if
			if thru_check = true then goto p1
		END IF
		''
		if w_casflags(depth,2) = 1 and w_casflags(depth+2,2) = 0 THEN
			ps = 25
			thru_check = attack(side,ps)
			if thru_check = false then
				ps = 24
				thru_check = attack(side,ps)
			end if
			if thru_check = true then goto p1
		end if

		goto p2

		pw1:
		IF b_casflags(depth,1) = 1 and b_casflags(depth+2,1) = 0 THEN
			ps = 95
			thru_check = attack(side,ps)
			if thru_check = false then
				ps = 96
				thru_check = attack(side,ps)
			end if
			if thru_check = true then goto p1
		END IF
		''
		If b_casflags(depth,2) = 1 and b_casflags(depth+2,2) = 0 THEN
			ps = 95
			thru_check = attack(side,ps)
			if thru_check = false then
				ps = 94
				thru_check = attack(side,ps)
			end if
			if thru_check = true then goto p1
		end if

		p2:



		xg = xg + 1 ' if here then must be a legal move

		score =  -ab_search(-side,depth-1,-beta, -alpha, epsqr(),w_casflags(),b_casflags(),fmove())


		p1:
		'

		Call unmake_move(side,depth,Pseu_Moves(),y,temp_val1(),epsqr(),w_casflags(),b_casflags(), wprom(),bprom(),fmove())



		'if perft = true or check = true then goto p4
		if check = true then goto p4
		if perft = true then goto p4
		'

		If score >= beta then return beta       ' if score 'too good' then cut-off search as opponent won't move here

		If score > alpha then alpha = score


		' If alpha = -9999 then alpha = (-9999 + search_depth) else if alpha = 9999 then alpha = (9999 - search_depth + depth)
		If alpha = -9999 then alpha = (-9999 + search_depth)
		if alpha = 9999 then alpha = (9999 - search_depth + depth)

		p4:
	Next y


	if xg = 0 and incheck(side) = true Then
		alpha = -9999 + search_depth  
	elseif xg = 0 and incheck(side) = false Then
		alpha = 0
	EndIf


	return alpha


end function


'///////////////////////////////////////////////////////////////////////////////
function evaluate(side) AS SINGLE

	Bbp = 0:Wbp = 0
	Bkn = 0:Wkn = 0
	'
	FOR K = 9 TO 2 STEP -1
		FOR L = 1 TO 8


			IF  B(K*10+L) = 0 THEN goto evl1

			IF  B(K*10+L) > 0 THEN goto lp1

			IF  B(K*10+L) = -1 THEN
				Material = Material - Pawn_Value
				if ENDGAME = 0 then
					Pos_Eval = Pos_Eval - BP_PST(K*10+L)
					if B(K*10+L-10) = -1 or B(K*10+L-20) = -1 or B(K*10+L-30) = -1 then Pos_Eval = Pos_Eval + 15   ' penalty for doubled pawns - added 4/1/09 in end5
					goto evl1
				end if
				Pos_Eval  = Pos_Eval - BP_end_PST(K*10+L)
				if B(K*10+L-10) = -1 or B(K*10+L-20) = -1 or B(K*10+L-30) = -1 then Pos_Eval = Pos_Eval + 30   ' penalty for doubled pawns - added 4/1/09 in end5
				bpp = true
				k1 = K - 1
				l1 = L - 1
				For x = k1 to 2 step - 1
					if B(x*10+l1) = 1 then bpp = false
				next x
				if bpp = false then goto evl1
				l1 = L
				For x = k1 to 2 step - 1
					if B(x*10+l1) = 1 then bpp = false
				next x
				if bpp = false then goto evl1
				l1 = L+1
				For x = k1 to 2 step - 1
					if B(x*10+l1) = 1 then bpp = false
				next x
				if bpp = false then goto evl1
				black_p_p = black_p_p + 1
				if black_p_p = 1 then
					bbp_sq1 = K*10+L
					bp1r = L
					bp1f = K
				end if
				if black_p_p = 2 then
					bbp_sq2 = K*10+L
					bp2r = L
					bp2f = K
				END IF
				goto evl1
			end if

			IF  B(K*10+L) = -4 THEN
				Material = Material - Rook_Value
				Pos_Eval = Pos_Eval - BRk_PST(K*10+L)
				Br_ev = 1
				goto evl1
			END IF

			IF  B(K*10+L) = -3 THEN
				Material = Material - Bishop_Value
				Pos_Eval = Pos_Eval - BBp_PST(K*10+L)
				Bbp = Bbp + 1
				goto evl1
			end if

			IF  B(K*10+L) = -2 THEN
				Material = Material - Knight_Value
				Pos_Eval = Pos_Eval - BKt_PST(K*10+L)
				Bkn = Bkn + 1
				goto evl1
			END IF

			IF  B(K*10+L) = -6 THEN
				Material = Material - Queen_Value
				Pos_Eval = Pos_Eval - BQn_PST(K*10+L)
				if ENDGAME = 1 THEN bqev = 1
				goto evl1
			end if


			lp1:


			IF  B(K*10+L) = 1 THEN
				Material = Material + Pawn_Value
				if ENDGAME = 0 then
					Pos_Eval = Pos_Eval + WP_PST(K*10+L)
					if B(K*10+L+10) = 1 or B(K*10+L+20) = 1 or B(K*10+L+30) = 1 then Pos_Eval = Pos_Eval - 15   ' penalty for doubled pawns - added 4/1/09 in end5
					goto evl1
				end if
				Pos_Eval  = Pos_Eval + WP_end_PST(K*10+L)
				if B(K*10+L+10) = 1 or B(K*10+L+20) = 1 or B(K*10+L+30) = 1 then Pos_Eval = Pos_Eval - 30   ' penalty for doubled pawns - added 4/1/09 in end5
				wpp = true
				k1 = K + 1
				l1 = L-1
				For x = k1 to 8
					if B(x*10+l1) = -1 then wpp = false
				next x
				if wpp = false then goto evl1
				l1 = L
				For x = k1 to 8
					if B(x*10+l1) = -1 then wpp = false
				next x
				if wpp = false then goto evl1
				l1 = L+1
				For x = k1 to 8
					if B(x*10+l1) = -1 then wpp = false
				next x
				if wpp = false then goto evl1
				white_p_p = white_p_p + 1
				if white_p_p = 1 then
					wpp_sq1 = K*10+L
					wp1r = L
					wp1f = K
				END IF
				if white_p_p = 2 then
					wpp_sq2 = K*10+L
					wp2r = L
					wp2f = K
				END IF
				goto evl1
			END IF


			IF  B(K*10+L) = 4 THEN
				Material = Material + Rook_Value
				Pos_Eval = Pos_Eval + WRk_PST(K*10+L)
				Wr_ev = 1
				goto evl1
			END IF

			IF  B(K*10+L) = 3 THEN
				Material = Material + Bishop_Value
				Pos_Eval = Pos_Eval + WBp_PST(K*10+L)
				Wbp = Wbp + 1
				goto evl1
			end if


			IF  B(K*10+L) = 2 THEN
				Material = Material + Knight_Value
				Pos_Eval = Pos_Eval + WKt_PST(K*10+L)
				Wkn = Wkn + 1
				goto evl1
			end if


			IF  B(K*10+L) = 6 THEN
				Material = Material + Queen_Value
				Pos_Eval = Pos_Eval + WQn_PST(K*10+L)
				if ENDGAME = 1 THEN wqev = 1
			end if

			evl1:

		NEXT l
	NEXT k



	If endgame = 1 then goto eg1

	Pos_Eval = Pos_Eval + WKg_PST(wkloc) - BKg_PST(bkloc)

	' trapped piece penalty

	If B(26) = 7 and (B(27) + B(28) = 4) THEN  Pos_Eval = Pos_Eval - 25  'trapped white king rook

	If B(27) = 7 and  (B(28) = 4 or B(38) = 4) THEN  Pos_Eval = Pos_Eval - 50

	if B(23) = 7 and (B(21) + B(22) = 4) THEN  Pos_Eval = Pos_Eval - 25

	If B(22) = 7 and  (B(21) = 4 or B(31) = 4) THEN  Pos_Eval = Pos_Eval - 50

	If B(96) = -7 and (B(97) + B(98) = -4) THEN  Pos_Eval = Pos_Eval + 25 ' trapped black king rook
	If B(97) = -7 and  (B(98) = -4 or  B(88) = -4) THEN  Pos_Eval = Pos_Eval + 50

	If B(93) = -7 and (B(92) + B(91) = -4) THEN  Pos_Eval = Pos_Eval + 25 ' trapped black king rook
	If B(92) = -7 and  (B(91) = -4 or B(81) = -4) THEN  Pos_Eval = Pos_Eval + 50


	If B(88) = 3 and B(77) = -1 and B(86) = -1 THEN  Pos_Eval = Pos_Eval - 25 ' trapped white bishop
	If B(81) = 3 and B(72) = -1 and B(74) = -1 THEN  Pos_Eval = Pos_Eval - 25

	If B(38) = -3 and B(47) = 1 and B(36) = 1 THEN  Pos_Eval = Pos_Eval + 25 ' trapped black bishop
	If B(31) = -3 and B(42) = 1 and B(34) = 1 THEN  Pos_Eval = Pos_Eval + 25

	If w_cas(1) = 1 and (B(36) + B(37)) <> 2 then Pos_Eval = Pos_Eval - 20 'penalty for lack of pawn protection if castled O-O
	If b_cas(1) = 1 and (B(86) + B(87)) <> -2 then Pos_Eval = Pos_Eval + 20
	'

	if endgame = 0 then goto ev1



	'**********************************
	' endgame evaluation
	' passed pawn
	'**********************************

	eg1:
	Pos_Eval = Pos_Eval + WKg_end_PST(wkloc) - BKg_end_PST(bkloc)


	if black_p_p + white_p_p = 0 then goto egc ' added 12/10/09 - to prevent endpos eval assessment when no passed pawns!

	if wpp_sq2 > wpp_sq1 then    ' only consider furthest advanced passed pawn
		wpp_sq1 = wpp_sq2
		wpp_sq2 = 0
		wp1r = wp2r
		wp2r = 0
		wp1f = wp2f
		wp2f = 0
	end if
	''
	if (bbp_sq2 <> 0) and bbp_sq2 < bbp_sq1 then
		bbp_sq1 = bbp_sq2
		bbp_sq2 = 0
		bp1r = bp2r
		bp2r = 0
		bp1f = bp2f
		bp2f = 0
	end if

	end_pos_eval = (white_p_p - black_p_p) * 30 + ((wp1f  * 10) - (-bp1f + 9)  * 10)  ' eval based on no pased pawns + bonus for progression


	if wr_ev = 0 and br_ev = 0 then goto egc ' minor speed advantage with no rooks on board in endgame

	if wpp_sq1 <> 0 then                            ' additional eval bonus if passed pawn is supported by rook
		rk_support = wpp_sq1
		pp_support = false
		pp_obst = false
		do
			rk_support = rk_support - 10
			if B(rk_support) = 4 then pp_support = true
		loop until B(rk_support) <> 0
		rk_support = wpp_sq1
		do
			rk_support = rk_support + 10
			if B(rk_support) <> 0 then pp_obst = true
		loop until rk_support > 90 and rk_support < 99
		If pp_obst = false AND PP_support = true then end_pos_eval = end_pos_eval + 40
	end if


	if bbp_sq1 <> 0 then
		brk_support = bbp_sq1
		bpp_support = false
		bpp_obst = false
		do
			brk_support = brk_support + 10
			if B(brk_support) = -4 then bpp_support = true
		loop until B(brk_support) <> 0
		brk_support = bbp_sq1
		do
			brk_support = brk_support - 10
			if B(brk_support) <> 0 then bpp_obst = true
		loop until brk_support > 20 and brk_support < 29
		If bpp_obst = false and bpp_support = true then end_pos_eval = end_pos_eval - 40
	end if

	egc:

	'code below to test for K outside square of pawn conditions - only engaged if opponent has no pieces
	Weg_condition4 = (BQ = 0 and bqev = 0 and br_ev = 0 and Bbp = 0 and Bkn = 0)

	Beg_condition4 = (WQ = 0 and wqev = 0 and wr_ev = 0 and Wbp = 0 and Wkn = 0)


	IF Weg_condition4 and wpp_sq1 <> 0 then
		r2prom = 9 - wp1f
		if side = black then r2prom = r2prom + 1
		King_inside = false
		prom_path = wpp_sq1
		scan = wpp_sq1
		do
			for h = -r2prom to r2prom
				if -h > (wp1r-1) or (h + wp1r > 8) then goto sc1 ' avoid wrap around on board
				scan = prom_path
				scan = scan + h
				if B(scan) = -7 then King_inside = true
				scan = prom_path
				sc1:
			next h
			prom_path = prom_path + 10
			scan = prom_path
		loop until scan > 98 or King_inside = true
		if king_inside = false then Material = Material + 800' if king can't catch pawn then increase material by 950 - 110 )ie Q less promoted pawn)
	END IF



	IF Beg_condition4 and bbp_sq1 <> 0 then
		br2prom = bp1f - 2
		if side = white then br2prom = br2prom + 1
		B_King_inside = false
		bprom_path = bbp_sq1
		do
			for h = -br2prom to br2prom
				if -h > (bp1r-1) or (h + bp1r > 8) then goto sc2    ' don't check further if hit edge of board marker
				b_scan = bprom_path
				b_scan = b_scan + h
				if B(b_scan) = 7 then B_King_inside = true
				sc2:
				b_scan = bprom_path

			next h
			bprom_path = bprom_path - 10
			b_scan = bprom_path
		loop until b_scan < 21 or B_King_inside = true
		SC3:
		if B_king_inside = false then Material = Material - 800 ' if king can't catch pawn then increase material by 950 - 110 )ie Q less promoted pawn)
	END IF


	ev1:

	EV = (Material + Pos_Eval + end_pos_eval)

	If side = black Then
		Eval = -EV 
	Else
		Eval = EV
	EndIf

	Return Eval


end function

'//////////////////////////////////////////////////////////////////////////////

function QS(Vo,side)

'
''***********************************************
''       Capture extension routine
''
''This routine is based on the 'swap-off' ideas
''explained by David Levy in his book 'Chess &
''Computers', see pages 44 - 48
''***********************************************
Dim FlipSwapOffB2W(4), FlipSwapOffW2B(4) 'array to flip swap off values depending on colour
Dim SwapOffAtk(5), SwapOffDef(5) ' array to hold swap off piece values
Dim bgain(5), wgain(5), tempgain(5) ' array to hold swap off values

K = cap_sq 'identify location sqr of leaf node capture

'reset flags/values
cpflag = 0  'capture flag
Atkno = 0  'number of captures by white
Defno = 0  'number of captures by black
SwapOffValue = 0
S = 0:T = 0
'
SWP_STM = Side

''change piece representation values to evaluation values where necessary
'

If abs(Vo) = 4 then Vo = 500
If abs(Vo) = 6 then Vo = 950
If abs(Vo) = 2 then Vo = 300
If abs(Vo) = 3 then Vo = 325
If abs(Vo) = 1 then Vo = 100

Atk_bp_list_pos = 0:Def_bp_list_pos = 0
Atk_Rk_list_pos = 0:Def_Rk_list_pos = 0

For t = 1 to 2  'loop through routine twice, once for each side
'
Side = -Side
'
IF Side = White Then
	L = -1 
ELSE 
	L = 1
EndIf

RR = K


''*******************************
''test for recapture by pawn
''*******************************

For u =  1 to 2

IF u = 1 then K = K + L * 9
IF u = 2 then K = K + (L * 11)


IF B(K) * Side = Pawn then
	If Side = SWP_STM then
		Atkno = Atkno + 1   'increment white capture counter
		SwapOffAtk(Atkno) = 100 'save swap-off piece value
	ElseIf Side = -SWP_STM then
		Defno = Defno + 1
		SwapOffDef(Defno) = 100
	end if
end If

K = RR
next u
'
''*******************************
''test for recapture by knight
''*******************************
'
FOR I = 9 TO 16
K = RR

K = K + Move_Offset(I)

IF B(K) = -99 THEN GOTO qs1

IF B(K) * Side = Knight then
	If Side = SWP_STM then
		Atkno = Atkno + 1   'increment white capture counter
		SwapOffAtk(Atkno) = 300 'save swap-off piece value
	ElseIf Side = -SWP_STM then
		Defno = Defno + 1
		SwapOffDef(Defno) = 300
	end if
end If

qs1:
NEXT I

K = RR
'
'*******************************
'test for recapture by bishop
'*******************************

FOR I = 1 TO 4
FOR J = 1 TO 7

K = K + Move_Offset(I)

IF B(K) = 0 THEN goto qs2

IF B(K) = -99 THEN
	J = 7
	GOTO qs2
END IF

IF B(K) * Side = Bishop THEN
	J = 7
	I = 4
	If Side = SWP_STM then
		Atkno = Atkno + 1
		Atk_bp_list_pos = Atkno
		SwapOffAtk(Atkno) = 325
		goto qs2
	ElseIf Side = -SWP_STM then
		Defno = Defno + 1
		Def_bp_list_pos = Defno
		SwapOffDef(Defno) = 325
		GOTO qs2
	end if
end If


IF B(K) * Side > 0 and B(K) * Side = Queen Then
	goto qs2 
ElseIf B(K) * Side > 0 then   'need to build in flag if bishop is behind Q
J = 7
GOTO qs2
END IF


IF B(K) * Side < 0 THEN
	J = 7
END IF

qs2:
NEXT J

K = RR

NEXT I

K = RR

''*******************************
''test for recapture by rook
''*******************************

FOR I = 5 TO 8
FOR J = 1 TO 7

K = K + Move_Offset(I)

IF B(K) = 0 THEN goto qs3

IF B(K) = -99 THEN
	J = 7
	GOTO qs3
END IF


IF B(K) * Side = Rook THEN
	'J = 7 ' change direction only (may be more than 1 rook!) - take out rooks may be doubled!
	If Side = SWP_STM then
		Atkno = Atkno + 1
		Atk_Rk_list_pos = Atkno
		SwapOffAtk(Atkno) = 500
		goto qs3
	ElseIf Side = -SWP_STM then
		Defno = Defno + 1
		Def_Rk_list_pos = Defno
		SwapOffDef(Defno) = 500
		GOTO qs3
	end if
end If


IF B(K) * Side > 0 and (B(K) * Side = Queen) Then
	goto qs3 
ElseIf B(K) * Side > 0 then
J = 7
GOTO qs3
END IF


IF B(K) * Side < 0 THEN
	J = 7
END IF

qs3:

NEXT J

K = RR

NEXT I


K = RR
''
'''*******************************
'''test for recapture by queen
'''*******************************
If (side = white and WQ = 0)  OR (side = black and BQ = 0) then goto qs4a ' ignore if no queen on board


FOR I = 1 TO 8

QF = 0

FOR J = 1 TO 7



K = K + Move_Offset(I)

IF B(K) = 0 THEN goto qs4

IF B(K) = -99 THEN
	J = 7
	GOTO qs4
END IF




IF B(K) * Side = Queen THEN
	'J = 7
	QF = 1
	If Side = SWP_STM then
		Atkno = Atkno + 1
		SwapOffAtk(Atkno) = 950
		goto qs4
	ElseIf Side = -SWP_STM then
		Defno = Defno + 1
		SwapOffDef(Defno) = 950
		GOTO qs4
	end if
end If


IF I < 5 AND QF = 1 AND B(K) * Side = Bishop THEN
	If Side = SWP_STM then
		SwapOffAtk(Atk_bp_list_pos) = 950
		SwapOffAtk(Atkno) = 325
		J = 7
		goto qs4
	ElseIf Side = -SWP_STM then
		SwapOffDef(Def_bp_list_pos) = 950
		SwapOffDef(Defno) = 325
		J = 7
		goto qs4
	End if
end If


IF I > 4 AND QF = 1 AND B(K) * Side = Rook THEN
	If Side = SWP_STM then
		SwapOffAtk(Atk_Rk_list_pos) = 950
		SwapOffAtk(Atkno) = 500
		J = 7
		goto qs4
	ElseIf Side = -SWP_STM then
		SwapOffDef(Def_Rk_list_pos) = 950
		SwapOffDef(Defno) = 500
		J = 7
		goto qs4
	End if
end If


IF I < 5 and B(K) * Side > 0 and (B(K) * Side = Bishop) then
	goto qs4
ElseIf I < 5 AND B(K) * Side > 0 then
	J = 7
	GOTO qs4
End IF

IF I > 4  and B(K) * Side > 0 and (B(K) * Side = Rook) then
	goto qs4
ElseIf I > 4 AND B(K) * Side > 0 then
	J = 7
	GOTO qs4
END IF



IF B(K) * Side < 0 THEN
	J = 7
END IF

qs4:

NEXT J

K = RR

NEXT I

K = RR

qs4a:
''*******************************
''test for recapture by king
''*******************************


FOR p = 1 TO 8  'directions for kings

K = K + Move_Offset(p)


IF B(K) * Side <> King THEN goto qs5
p = 8 ' only 1 king so if found can't repeat!
If Side = SWP_STM then
	Atkno = Atkno + 1
	SwapOffAtk(Atkno) = 9999
	goto qs5
ElseIf Side = -SWP_STM then
	Defno = Defno + 1
	SwapOffDef(Defno) = 9999
	GOTO qs5
end If


qs5:

K = RR

NEXT p

K = RR



next t


If Atkno = 0 then goto qs20 ' nothing to take with!

If Atkno + Defno = 0 then goto qs20 ' if flag not set then no swap-off value to do

If Defno >= Atkno Then
	u2 = Atkno 
elseif Defno < Atkno Then
	u2 = Defno + 1
EndIf

for x = 1 to u2  ' assume that there won't be more than 8 successive recaptures!

	if x = 1 then
		wgain(x) = Vo -(SwapOffAtk(x))
		bgain(x) = Vo
	end if

	if x = 2 then
		wgain(x) = Vo - (SwapOffAtk(x-1)) + (SwapOffDef(x-1)) - (SwapOffAtk(x))
		bgain(x) = Vo - (SwapOffAtk(x-1)) + (SwapOffDef(x-1))
	end if

	if x = 3 then
		wgain(x) = Vo - (SwapOffAtk(x-2)) + (SwapOffDef(x-2)) - (SwapOffAtk(x-1)) +  (SwapOffDef(x-1)) - (SwapOffAtk(x))
		bgain(x) = Vo - (SwapOffAtk(x-2)) + (SwapOffDef(x-2)) - (SwapOffAtk(x-1)) +  (SwapOffDef(x-1))
	end if
	'
	if x = 4 then
		wgain(x) = Vo - (SwapOffAtk(x-3)) + (SwapOffDef(x-3)) - (SwapOffAtk(x-2)) +  (SwapOffDef(x-2)) - (SwapOffAtk(x-1)) + (SwapOffDef(x-1)) - (SwapOffAtk(x))
		bgain(x) = Vo - (SwapOffAtk(x-3)) + (SwapOffDef(x-3)) - (SwapOffAtk(x-2)) +  (SwapOffDef(x-2))- (SwapOffAtk(x-1)) +  (SwapOffDef(x-1))
	end if


next x


if Defno >= Atkno Then
	bgain(u2+1) = wgain(u2) 
Else
	wgain(u2) = bgain(u2) ' insert last value replica
EndIf


for i = 1 to u2
	'
	if i = 1 then
		id1 = wgain(i)
		id = i
		pid1 = bgain(i)
		pid = i
	END IF

	if i > 1 and id1 < wgain(i) then
		id1 = wgain(i)
		id = i
	end if

	if i > 1 and pid1 > bgain(i) then
		pid1 = bgain(i)
		pid = i
	end if

	if Defno >= Atkno and i = u2 and pid1 > bgain(u2+1) then
		pid1 = bgain(u2+1)
		pid = u2+1
	end if

next i

id_copy = id
pid_copy = pid


if Defno > = Atkno then
	Stemp = id1
	do
		if bgain(id_copy) < Stemp then Stemp = bgain(id_copy)
		id_copy = id_copy - 1
	loop until id_copy <=  1
end if

If Defno < Atkno then
	Stemp = pid1
	do
		if wgain(pid_copy) > Stemp then Stemp = wgain(pid_copy)
		pid_copy = pid_copy - 1
	loop until pid_copy <= 1
end if


qs20:

RETURN Stemp


end function





'/////////////////////////////////////////////////////////////////////////////
function assessboard(side,best_score AS SINGLE)

game_end = false

if fifty_move = 100 and WinboardMode = 1 then
	SendCommand("1/2-1/2 {Draw by 50 move rule}")
	game_end = true
	exit function
elseif fifty_move = 100 and WinboardMode = 0 then
	call display()
	Print "Draw by 50 move rule!"
	game_end = true
	goto asb7
end if

Side = -Side

depth = 1
'nb line below commented out 14/11/11 as engine was resigning instead of playing pxpep to escape from checkmate; line below is too restrictive as pxpep can be valid option to escape mate - needed to add in line 2634
'epsqr(depth) = -1 ' ignore ep square in genmove as we are testing if own side is in check therefore not relevant eg 1 f3 e5 2 g4 Qh4++ (ep should not be 47 otherwise hg is recorded as possible move)
if act_epsq <> -1 then epsqr(depth) = act_epsq  'set ep sqr if computer last moved pawn 2 squares
b_casflags(3,1)  = 0:b_casflags(3,2) = 0  ' need to reset search flags for ply 3 before generating moves to test legality

w_casflags(3,1)  = 0:w_casflags(3,2) = 0

CALL gen_move(side,depth,epsqr(),w_casflags(),b_casflags())


valid_move = false

for w = 1 to Pseu_Moves(depth)
	MoveFrom = Move_List(depth,w,1): MoveTo = Move_List(depth,w,2)

	'handle special moves
	If side = black then goto asb1

	If MoveFrom = 25 and MoveTo = 27 and B(25) = 7 and w_cas(1) = 0 THEN
		ps = 25              ' set attack sq to see if castle through check
		thru_check = attack(side,ps) 'test to see if sq is attacked
		ps = 26              'if not, then try next sq (don't need to try sq27 Kg1 - this will be picked up by 'check_root' below
		thru_check = attack(side,ps)
		if thru_check = false and (B(36) <> -7 and B(37) <> -7 and B(38) = -7) then valid_move = true ' if check found undo move
	END IF


	If MoveFrom = 25 and MoveTo = 23 and B(25) = 7 and w_cas(2) = 0 THEN
		ps = 25              ' set attack sq to see if castle through check
		thru_check = attack(side,ps) 'test to see if sq is attacked
		ps = 24              'if not, then try next sq (don't need to try sq27 Kg1 - this will be picked up by 'check_root' below
		thru_check = attack(side,ps)
		if thru_check = false and (B(22) <> -7 and B(32) <> -7 and B(33) <> -7 and B(34) <> -7) then valid_move = true ' if check found undo move
	END IF

	goto asb2

	asb1:
	If MoveFrom = 95 and MoveTo = 97 and B(95) = -7 and b_cas(1) = 0 THEN
		ps = 95              ' set attack sq to see if castle through check
		thru_check = attack(side,ps) 'test to see if sq is attacked
		ps = 96              'if not, then try next sq (don't need to try sq27 Kg1 - this will be picked up by 'check_root' below
		thru_check = attack(side,ps)
		if thru_check = false and (B(86) <> 7 and B(87) <> 7 and B(88) <> 7) then valid_move = true ' if check found undo move
	END IF


	If MoveFrom = 95 and MoveTo = 93 and B(95) = -7 and b_cas(2) = 0 THEN
		ps = 95              ' set attack sq to see if castle through check
		thru_check = attack(side,ps) 'test to see if sq is attacked
		ps = 94              'if not, then try next sq (don't need to try sq27 Kg1 - this will be picked up by 'check_root' below
		thru_check = attack(side,ps)
		if thru_check = false and (B(82) = 7 and B(83) = 7 and B(84) = 7) then valid_move = true ' if check found undo move
	END IF

	asb2:


	temp_user_var = B(MoveTo)
	B(MoveTo) = B(MoveFrom)
	B(MoveFrom) = 0

	If B(MoveTo) = 7 Then
		wkloc = MoveTo 
	elseif B(MoveTo) = -7 Then
		bkloc = MoveTo
	EndIf

	Check_root = incheck(side)  ' test to see if move results in check


	If Check_root = True Then
		valid_move = false 
	else 
		valid_move = true         ' if so then illegal and take-back move
	EndIf

	If (Check_root = True and B(MoveTo) = 1 and MoveTo = epsqr(depth)) or (Check_root = True and B(MoveTo) = -1 and MoveTo = epsqr(depth)) then valid_move = true 'valid move if get out check by PxPep!

	B(MoveFrom) = B(MoveTo)       'undo move
	B(MoveTo) =  temp_user_var

	if B(MoveFrom) = 7 Then
		wkloc = MoveFrom 
	elseif B(MoveFrom) = -7 Then
		bkloc = MoveFrom
	EndIf

	If valid_move = True then w = Pseu_Moves(depth)  ' only need 1 valid move - no need to continue if a valid move is found

next w


asb3:


if valid_move = false and incheck(side) = false Then
	SM = 1 
Else
	SM = 0
EndIf
if valid_move = false and incheck(side) = true Then
	CM = 1 
ELSE 
	CM = 0
EndIf

Side = -Side


if STM = Opponent then goto asb4


if WinboardMode = 1 and CM = 1 and Side = White then ' changed 4/10/09 following bug report from Leo - was black
	SendCommand("1-0 {Checkmate - Lost again!}")
	game_end = true
	goto asb7
end if

if WinboardMode = 1 and CM =1 and Side = Black then ' changed 4/10/09 following bug report from Leo - was white
	SendCommand("0-1 {Checkmate - Lost again!}")
	game_end = true
	goto asb7
end if

IF winboardmode = 0 and CM = 1 then
	call display()
	print "Congratulations! - checkmate you win!"
	game_end = true
	goto asb7
end if


IF SM = 1 and WinboardMode = 0 then
	call display()
	print "Draw by stalemate!"
	game_end = true
	goto asb7
end if

if Winboardmode = 1 and SM = 1 then
	SendCommand("1/2-1/2 {Stalemate}")
	game_end = true
	goto asb7
end if

goto asb5


asb4:

if WinboardMode = 1 and CM = 1 and Side = Black then
	SendCommand("0-1 {Checkmate - I won!}")
	game_end = true
end if

if WinboardMode = 1 and CM =1 and Side = White then
	SendCommand("1-0 {Checkmate - I won!}")
	game_end = true
end if

IF winboardmode = 0 and CM = 1 then
	call display()
	print "Checkmate - I win!"
	game_end = true
	goto asb7
end if

IF SM = 1 and WinboardMode = 0 then
	call display()
	print "Draw by stalemate!"
	game_end = true
	goto asb7
end if

If Winboardmode = 1 and SM = 1 then
	SendCommand("1/2-1/2 {Stalemate}")
	game_end = true
	goto asb7
end if

asb5:

if WinboardMode = 1 and IM = 1 then
	SendCommand("1/2-1/2 {Draw by insufficient material}")
	game_end = true
ElseIf WinboardMode = 0 AND IM = 1 THEN
	call display()
	print "Draw by insufficient material!"
	game_end = true
end if

'
if game_end = true then goto asb7

asb6:

rep_pos = 0
posit$ = ""
N1 = 0
FOR X = 9 TO 2 STEP -1
	FOR Y = 1 TO 8
		IF B(X*10 + Y) = 0 THEN
			N1 = N1 + 1: GOTO rp4
		END IF
		IF N1 = 0 GOTO rp2
		N1$ = STR$(N1)
		posit$ = posit$ + RIGHT$(N1$,LEN(N1$))
		N1 = 0

		rp2:
		I1 = B(X*10 + Y)
		IF I1 < 0 GOTO rp3
		posit$ = posit$ + B$(I1)
		GOTO rp4
		rp3:
		posit$ = posit$ + B$(I1 + 20)
		rp4:
	NEXT Y
NEXT X

If N1 <> 0 then   'added 15/10/09 (from N04C3 version - failing to pick up blank squares at end of posit (see rep_check)
	N1$ = STR$(N1)
	posit$ = posit$ + RIGHT$(N1$,LEN(N1$))
end if


''store current game position
If Side = White Then
	Pos_State_W$(MoveNo) = posit$ 
Else
	Pos_State_B$(MoveNo) = posit$
EndIf

if Side = Black then goto rp5
'
'trip though all previous positions and compare with current board position
For t = 1 to MoveNo '
	if posit$ = Pos_State_W$(t) then
		rep_pos = rep_pos + 1
	end if
next
'
goto rp6
'
rp5:
For t = 1 to MoveNo
	if posit$ = Pos_State_B$(t) then
		rep_pos = rep_pos + 1
	end if
next
'
'
rp6:

If rep_pos = 3 then
	game_end = true
	if WinboardMode = 1 then
		SendCommand("1/2-1/2 {Draw by repetition}")
	else
		call display()
		print "Draw by 3 fold repetition!!!!"
	end if
end if


asb7:

return game_end

end function




'/////////////////////////////////////////////////////////////////
function rep_check(side)

	rep_draw = false
	wht_ingame_rep_pos = 0:blk_ingame_rep_pos = 0
	ingame_posit$ = ""

	RC = 0

	FOR X = 9 TO 2 STEP -1
		FOR Y = 1 TO 8

			IF B(X*10 + Y) = 0 THEN
				RC = RC + 1
				GOTO repc4
			END IF

			IF RC = 0 GOTO repc2

			RC$ = STR$(RC)

			ingame_posit$ = ingame_posit$ + RIGHT$(RC$,LEN(RC$))

			RC = 0

			repc2:
			IRC1 = B(X*10 + Y)

			IF IRC1 < 0 Then
				ingame_posit$ = ingame_posit$ + B$(IRC1 + 20) 
			Else
				ingame_posit$ = ingame_posit$ + B$(IRC1)
			EndIf

			repc4:
		NEXT Y
	NEXT X

	If RC <> 0 then   'added 15/10/09 - failing to pick up blank squares at end of ingame_posit
		RC$ = STR$(RC)
		ingame_posit$ = ingame_posit$ + RIGHT$(RC$,LEN(RC$))
	end if

	'trip though positions from last 7 moves and compare with current board position
	For t = MoveNo to (MoveNo - 7) Step -1 '
		if ingame_posit$ = Pos_State_W$(t) then wht_ingame_rep_pos = wht_ingame_rep_pos + 1
		if ingame_posit$ = Pos_State_B$(t) then blk_ingame_rep_pos = blk_ingame_rep_pos + 1

	next


	If side = white and (wht_ingame_rep_pos >= 1) then rep_draw = true ' only 1 because already have board which makes 2 (return 0.00 after 2nd rep for safety)
	If side = black and (blk_ingame_rep_pos >= 1) then rep_draw = true 'as above



	return rep_draw

end function


'///////////////////////////////////////////////////////////////////////////////
function make_move(side,depth,Pseu_Moves(),y,epsqr(),w_casflags(),b_casflags(), wprom(),bprom(),fmove())',wkcas,wqcas,bkcas,bqcas)


	'Print "before make move..."
	'
	'FOR X = 9 TO 2 STEP -1
	'    FOR Yl = 1 TO 8
	'        Print B(X*10+Yl);
	'
	'    NEXT Yl
	'    print
	'NEXT X
	'Print
	'sleep
	'''

	IF Side = White Then
		EP_PL = 1 
	ELSE 
		EP_PL = -1
	EndIf


	' white ep code - ie set ep square and deal with any white ep capture of black pawn
	''
	IF (Move_List(depth,y,2) - Move_List(depth,y,1) = EP_PL*20) and B(Move_List(depth,y,1)) = (EP_PL*1) and (B(Move_List(depth,y,2)-1) = -EP_PL or B(Move_List(depth,y,2)+1) = -EP_PL) then
		epsqr(depth-1) = Move_List(depth,y,1) + (EP_PL*10)
	else 
		epsqr(depth-1) = -1 ' no ep square found
	end if


	if (Move_List(depth,y,2) - Move_List(depth,y,1) <> EP_PL*11 and Move_List(depth,y,2) - Move_List(depth,y,1) <> EP_PL*9) or (B(Move_List(depth,y,1)) <> EP_PL) then goto m1


	if (Move_List(depth,y,2) = epsqr(depth)) and B(epsqr(depth)) = 0 then B(epsqr(depth)+(-EP_PL*10)) = 0 ' take off pawn


	m1:

	'castle code
	if side = black then goto mm1


	w_casflags(depth,1) = w_casflags(depth+2,1)
	w_casflags(depth,2) = w_casflags(depth+2,2)

	'

	If Move_List(depth,y,1) = 25 and Move_List(depth,y,2) = 27 and B(Move_List(depth,y,1)) = 7  then
		w_casflags(depth,1) = 1
		B(28) = 0: B(26) = 4 ' move rook
	end if


	If Move_List(depth,y,1) = 25 and Move_List(depth,y,2) = 23 and B(Move_List(depth,y,1)) = 7  then
		w_casflags(depth,2) = 1
		B(21) = 0: B(24) = 4
	end if

	goto mm2



	mm1:

	' Black castle moves


	b_casflags(depth,1) = b_casflags(depth+2,1)
	b_casflags(depth,2) = b_casflags(depth+2,2)

	'

	If Move_List(depth,y,1) = 95 and Move_List(depth,y,2) = 97 and B(Move_List(depth,y,1)) = -7 then
		b_casflags(depth,1) = 1
		B(98) = 0: B(96) = -4
	END IF
	'
	If Move_List(depth,y,1) = 95 and Move_List(depth,y,2) = 93 and B(Move_List(depth,y,1)) = -7 then
		b_casflags(depth,2) = 1
		B(91) = 0: B(94) = -4
	END IF

	' make move

	mm2:


	temp_val1(depth) = B(Move_List(depth,y,2))
	B(Move_List(depth,y,2)) = B(Move_List(depth,y,1))
	B(Move_List(depth,y,1)) = 0


	cap_sq = Move_List(depth,y,2)             'save capture square for swap off extension
	init_swp_val = B(Move_List(depth,y,2))    'save piece value for swap off extension

	'Print "make move.."; Move_List(depth,y,1); "-"; Move_List(depth,y,2); " ";depth'; '"casflags(depth,1) = ";casflags(depth,1)
	'sleep 6000


	''insearch 50  move rule test - removed 21/2/2010 (c5% speed up in total)

	'    IF temp_val1(depth) <> 0 OR B(Move_List(depth,y,2)) = 1 OR B(Move_List(depth,y,2)) = -1 THEN
	'        fmove(depth) = 0
	'    else
	'       fmove(depth) = fmove(depth+1) + 1
	'        end if
	'

	if side = black then goto mp1

	if B(Move_List(depth,y,2)) = 7 then wkloc = Move_List(depth,y,2)


	If w_casflags(depth,1) <> 1 and (B(25) <> 7 or B(28) <> 4) THEN w_casflags(depth,1) = -1
	If w_casflags(depth,2) <> 1 and (B(25) <> 7 or B(21) <> 4) THEN w_casflags(depth,2) = -1

	if Move_List(depth,y,2) > 90 and B(Move_List(depth,y,2)) = 1 Then
		wprom(depth) = 1 
	Else
		wprom(depth) = 0
	EndIf

	if wprom(depth) = 0 then return temp_val1(depth)'goto mp2

	if Move_List(depth,y,3) = 6 then B(Move_List(depth,y,2)) = 6
	if Move_List(depth,y,3) = 4 then B(Move_List(depth,y,2)) = 4
	if Move_List(depth,y,3) = 3 then B(Move_List(depth,y,2)) = 3
	if Move_List(depth,y,3) = 2 then B(Move_List(depth,y,2)) = 2

	return temp_val1(depth)


	mp1:

	if B(Move_List(depth,y,2)) = -7 then bkloc = Move_List(depth,y,2)

	If b_casflags(depth,1) <> 1 and (B(95) <> -7 or B(98) <> -4) THEN b_casflags(depth,1) = -1
	If b_casflags(depth,2) <> 1 and (B(95) <> -7 or B(91) <> -4) THEN b_casflags(depth,2) = -1

	if Move_List(depth,y,2) < 29 and B(Move_List(depth,y,2)) = -1 Then
		bprom(depth) = 1 
	else 
		bprom(depth) = 0
	EndIf

	if bprom(depth) = 0 then return temp_val1(depth)'goto mp2

	if Move_List(depth,y,3) = -6 then B(Move_List(depth,y,2)) = -6
	if Move_List(depth,y,3) = -4 then B(Move_List(depth,y,2)) = -4
	if Move_List(depth,y,3) = -3 then B(Move_List(depth,y,2)) = -3
	if Move_List(depth,y,3) = -2 then B(Move_List(depth,y,2)) = -2

	'mp2:


	'   Print
	'
	'FOR X = 9 TO 2 STEP -1
	'    FOR Yl = 1 TO 8
	'        Print B(X*10+Yl);
	'
	'    NEXT Yl
	'    print
	'NEXT X
	'Print
	'sleep


	return temp_val1(depth)

	mm3:

end function
'///////////////////////////////////////////////////////////////////////////////

'///////////////////////////////////////////////////////////////////////////////
function unmake_move(side,depth,Pseu_Moves(),y,temp_val1(),epsqr(),w_casflags(),b_casflags(), wprom(),bprom(),fmove())',wkcas,wqcas,bkcas,bqcas)


	IF Side = White Then
		EP_PL = 1 
	Else
		EP_PL = -1
	EndIf

	if ((Move_List(depth,y,2) - Move_List(depth,y,1) <> EP_PL * 11) and (Move_List(depth,y,2) - Move_List(depth,y,1) <> EP_PL * 9)) or (B(Move_List(depth,y,2)) <> EP_PL) then goto um1

	if Move_List(depth,y,2) = epsqr(depth) then B(epsqr(depth)+(-EP_PL*10)) = -EP_PL



	um1:
	if side = black then goto um8

	if Move_List(depth,y,2) = 27 and Move_List(depth,y,1) = 25 and B(Move_List(depth,y,2)) = 7 then
		B(26) = 0:B(28) = 4
		w_casflags(depth,1) = 0
	end if

	if Move_List(depth,y,2) = 23 and Move_List(depth,y,1) = 25 and B(Move_List(depth,y,2)) = 7 then
		B(24) = 0:B(21) = 4
		w_casflags(depth,2) = 0
	end if

	goto um10:



	um8:


	if Move_List(depth,y,2) = 97 and Move_List(depth,y,1) = 95 and B(Move_List(depth,y,2)) = -7 then
		B(96) = 0:B(98) = -4
		b_casflags(depth,1) = 0
	end if

	if Move_List(depth,y,2) = 93 and Move_List(depth,y,1) = 95 and B(Move_List(depth,y,2)) = -7 then
		B(94) = 0:B(91) = -4
		b_casflags(depth,2) = 0
	end if


	um10:
	B(Move_List(depth,y,1)) = B(Move_List(depth,y,2))
	B(Move_List(depth,y,2)) = temp_val1(depth)



	'insearch 50  move rule test - removed 21/2/2010 (c5% speed up in total)

	'        IF temp_val1(depth) <> 0 OR B(Move_List(depth,y,2)) = 1 OR B(Move_List(depth,y,2)) = -1 THEN
	'        fmove(depth) = fmove(depth+1)
	'        ELSE fmove(depth) = fmove(depth) - 1
	'        end if
	'

	if B(Move_List(depth,y,1)) = 7 then wkloc = Move_List(depth,y,1)
	if B(Move_List(depth,y,1)) = -7 then bkloc = Move_List(depth,y,1)

	if side = black then goto u11
	'
	If w_casflags(depth,1) <> -1 and (B(25) = 7 and B(28) = 4) THEN w_casflags(depth,1) = 0
	If w_casflags(depth,2) <> -1 and(B(25) = 7 and B(21) = 4) THEN w_casflags(depth,2) = 0

	if wprom(depth) <> 1 then exit function 'goto u12

	if Move_List(depth,y,2) > 90 and B(Move_List(depth,y,1)) = 6 and Move_List(depth,y,3) = 6 then B(Move_List(depth,y,1)) = 1
	if Move_List(depth,y,2) > 90 and B(Move_List(depth,y,1)) = 4 and Move_List(depth,y,3) = 4 then B(Move_List(depth,y,1)) = 1
	if Move_List(depth,y,2) > 90 and B(Move_List(depth,y,1)) = 3 and Move_List(depth,y,3) = 3 then
		B(Move_List(depth,y,1)) = 1
		Wbp = Wbp - 1    ' 17/1/09 - reduce no white bishops (ie undo promoted bishop) - needed to avoid incorrect draw by insufficient material
	end if
	if Move_List(depth,y,2) > 90 and B(Move_List(depth,y,1)) = 2 and Move_List(depth,y,3) = 2 then
		B(Move_List(depth,y,1)) = 1
		Wkn = Wkn - 1   ' 17/1/09 - reduce no white Kn (ie undo promoted Kn) - needed to avoid incorrect draw by insufficient material
	end if          ' don't worry about Q & R because can still mate - don't worry about no Queens coz if incremented for promoted Q then endgame eval won't kick in (ie K goes to corners)

	exit function

	'
	u11:
	If b_casflags(depth,1) <> -1 and (B(95) = -7 and B(98) = -4) THEN b_casflags(depth,2) = 0'b_casflags(depth,1) = b_casflags(depth,1)
	If b_casflags(depth,2) <> -1 and (B(95) = -7 and B(91) = -4) THEN b_casflags(depth,2) = 0

	if bprom(depth) <> 1 then exit function'goto u12

	if Move_List(depth,y,2) < 29 and B(Move_List(depth,y,1)) = -6 and Move_List(depth,y,3) = -6 then B(Move_List(depth,y,1)) = -1
	if Move_List(depth,y,2) < 29 and B(Move_List(depth,y,1)) = -4 and Move_List(depth,y,3) = -4 then B(Move_List(depth,y,1)) = -1
	if Move_List(depth,y,2) < 29 and B(Move_List(depth,y,1)) = -3 and Move_List(depth,y,3) = -3 then
		B(Move_List(depth,y,1)) = -1
		Bbp = Bbp - 1
	end if
	if Move_List(depth,y,2) < 29 and B(Move_List(depth,y,1)) = -2 and Move_List(depth,y,3) = -2 then
		B(Move_List(depth,y,1)) = -1
		Bkn = Bkn - 1
	end if



	u12:
	'pRINT "Unmake move.."; "depth = "; depth
	'Print
	'
	'FOR X = 9 TO 2 STEP -1
	'    FOR Yl = 1 TO 8
	'        Print B(X*10+Yl);
	'
	'    NEXT Yl
	'    print
	'NEXT X
	'Print
	'Print "move = "; Move_List(depth,y,1); "-"; Move_List(depth,y,2); " depth = ";depth; " ";'Move_List(depth,y,3)' " W1 = ";w_casflags(1)
	'sleep
	''
	Function=0
end function
'///////////////////////////////////////////////////////////////////////////////




'///////////////////////////////////////////////////////////////////////////////
function gen_move(side,depth,epsqr(),w_casflags(),b_casflags())

	' *************************************
	'      Generate legal moves
	'  (this routine is called for both
	'  engine and human moves)
	'*************************************

	Pseu_Moves(depth) = 0 ' reset counter


	For Sq = 21 to 98


		If B(Sq) = 0 then goto g_m_next ' if empty loop back
		if B(Sq) * Side < 0 then goto g_m_next ' if opponent ...
		if B(Sq) = -99 then goto g_m_next ' if off board ....

		Piece = ABS(B(Sq)) ' establish absolute piece value (ie Knight, Bishop etc)

		SELECT CASE Piece
			CASE 1
				Goto fh1
			CASE 2
				Goto  m_g1
			CASE 3
				Goto m_g2
			CASE 4
				Goto  m_g3
			CASE 6
				Goto  m_g2
			CASE 7
				Goto m_g4
		END SELECT



		'***** White pawn moves *****

		fh1:
		If Side = Black then goto b_p_m



		For I = 1 to 2  ' captures first

			Pawn_Move = Sq + Move_Offset(I)

			If B(Pawn_Move) > 0 then goto w_p1 'if error loop again
			If B(Pawn_Move) = -99 then goto w_p1 'if error loop again

			IF Pawn_Move = epsqr(depth) and B(Pawn_Move) = 0 then goto wep1


			If B(Pawn_Move) = 0 THEN GOTO w_p1  'loop if not En passant

			IF Pawn_Move > 90 THEN
				for m =  1 to 4
					Pseu_Moves(depth) = Pseu_Moves(depth) + 1
					Move_List(Depth,Pseu_Moves(depth),1) = Sq:  Move_List(Depth,Pseu_Moves(depth),2) = Pawn_Move
					IF m = 1 then Move_List(Depth,Pseu_Moves(depth),3) = 6
					IF m = 2 then Move_List(Depth,Pseu_Moves(depth),3) = 4
					IF m = 3 then Move_List(Depth,Pseu_Moves(depth),3) = 3
					IF m = 4 then Move_List(Depth,Pseu_Moves(depth),3) = 2
				next m
				goto w_p1
			end if

			wep1:
			Pseu_Moves(depth) = Pseu_Moves(depth) + 1
			Move_List(Depth,Pseu_Moves(depth),1) = Sq:  Move_List(Depth,Pseu_Moves(depth),2) = Pawn_Move
			w_p1:
		Next I
		'
		For J = 1 to 2 ' non-capture pawn moves

			Pawn_Move = Sq + Pawn_Offset(J)

			IF J = 1 and Sq > 38 THEN GOTO w_p2
			IF J = 1 AND B(Pawn_Move-10) <> 0 then GOTO w_p2


			If B(Pawn_Move) <> 0 then GOTO w_p2 ' pawn can't move onto occupied square!

			IF Pawn_Move > 90 THEN
				for m =  1 to 4
					Pseu_Moves(depth) = Pseu_Moves(depth) + 1
					Move_List(Depth,Pseu_Moves(depth),1) = Sq:  Move_List(Depth,Pseu_Moves(depth),2) = Pawn_Move
					IF m = 1 then Move_List(Depth,Pseu_Moves(depth),3) = 6
					IF m = 2 then Move_List(Depth,Pseu_Moves(depth),3) = 4
					IF m = 3 then Move_List(Depth,Pseu_Moves(depth),3) = 3
					IF m = 4 then Move_List(Depth,Pseu_Moves(depth),3) = 2
				next m
				goto w_p2
			end if

			Pseu_Moves(depth) = Pseu_Moves(depth) + 1
			Move_List(Depth,Pseu_Moves(depth),1) = Sq: Move_List(Depth,Pseu_Moves(depth),2) = Pawn_Move
			'
			w_p2:
		Next J
		'
		Goto g_m_next
		'
		b_p_m:
		''***** Black pawn moves *****

		For I = 1 to 2  ' captures first

			Pawn_Move = Sq + Move_Offset(I+2)

			If B(Pawn_Move) < 0 then goto b_p1
			If B(Pawn_Move) = -99 then goto b_p1 'if error loop again

			IF Pawn_Move = epsqr(depth)and B(Pawn_Move) = 0 then goto bep1


			IF B(Pawn_Move) = 0 then goto b_p1

			IF Pawn_Move < 29 THEN
				for m =  1 to 4
					Pseu_Moves(depth) = Pseu_Moves(depth) + 1
					Move_List(Depth,Pseu_Moves(depth),1) = Sq:  Move_List(Depth,Pseu_Moves(depth),2) = Pawn_Move
					IF m = 1 then Move_List(Depth,Pseu_Moves(depth),3) = -6
					IF m = 2 then Move_List(Depth,Pseu_Moves(depth),3) = -4
					IF m = 3 then Move_List(Depth,Pseu_Moves(depth),3) = -3
					IF m = 4 then Move_List(Depth,Pseu_Moves(depth),3) = -2
				next m
				goto b_p1
			end if


			bep1:
			Pseu_Moves(depth) = Pseu_Moves(depth) + 1
			Move_List(Depth,Pseu_Moves(depth),1) = Sq: Move_List(Depth,Pseu_Moves(depth),2) = Pawn_Move

			b_p1:
		Next I

		For I = 1 to 2 ' non-capture pawn moves
			'
			Pawn_Move = Sq + Pawn_Offset(I+2)

			IF I = 1 and Sq < 81 then goto b_p2  ' pawn must be on 2nd rank to advance 2
			IF I = 1 and B(Pawn_Move+10) <> 0 then GOTO b_p2


			If B(Pawn_Move) <> 0 then GOTO b_p2 ' pawn can't move onto occupied square!

			IF Pawn_Move < 29 THEN
				for m =  1 to 4
					Pseu_Moves(depth) = Pseu_Moves(depth) + 1
					Move_List(Depth,Pseu_Moves(depth),1) = Sq:  Move_List(Depth,Pseu_Moves(depth),2) = Pawn_Move
					IF m = 1 then Move_List(Depth,Pseu_Moves(depth),3) = -6
					IF m = 2 then Move_List(Depth,Pseu_Moves(depth),3) = -4
					IF m = 3 then Move_List(Depth,Pseu_Moves(depth),3) = -3
					IF m = 4 then Move_List(Depth,Pseu_Moves(depth),3) = -2
				next m
				goto b_p2
			end if

			Pseu_Moves(depth) = Pseu_Moves(depth) + 1
			Move_List(Depth,Pseu_Moves(depth),1) = Sq: Move_List(Depth,Pseu_Moves(depth),2) = Pawn_Move

			b_p2:
		Next I

		goto g_m_next

		m_g1:
		'    ''***** knight legal moves  *****
		'
		'' generate Knight moves

		For N = 9 to 16
			KhtMove = Sq + Move_Offset(N)
			If B(KhtMove) = -99 THEN goto k_n
			IF Side = White and B(KhtMove) > 0 THEN goto k_n
			IF Side = Black and B(KhtMove) < 0 then goto k_n
			IF B(KhtMove) * Side = -King then goto k_n ' can't take king!

			Pseu_Moves(depth) = Pseu_Moves(depth) + 1
			Move_List(Depth,Pseu_Moves(depth),1) = Sq: Move_List(Depth,Pseu_Moves(depth),2) = KhtMove
			k_n:
		NEXT N
		'
		Goto g_m_next

		m_g2:
		'

		''***** Non-pinned Bishop legal moves *****
		'
		FOR N = 1 TO 4       ' bishop can move in 4 directions
			FOR M = 1 TO 7    ' for a maximum of 7 squares
				'
				BpMove = Sq + Move_Offset(N) * M
				'
				'            IF (B(BpMove) = -99) OR (B(BpMove) * Side > 0) OR (B(BpMove) * Side = -King) THEN
				'                M = 7
				'                GOTO b_p
				'            END IF
				''
				IF (B(BpMove) * Side > 0) THEN
					M = 7
					GOTO b_p
				END IF

				IF (B(BpMove) = -99) THEN
					M = 7
					GOTO b_p
				END IF

				IF (B(BpMove) * Side = -King) THEN
					M = 7
					GOTO b_p
				END IF

				IF B(BpMove) * Side < 0 THEN M = 7

				Pseu_Moves(depth) = Pseu_Moves(depth) + 1
				'
				Move_List(Depth,Pseu_Moves(depth),1) = Sq: Move_List(Depth,Pseu_Moves(depth),2) = BpMove
				'
				b_p:
			NEXT M
		NEXT N
		'
		If Piece <> Queen then Goto g_m_next
		'
		m_g3:
		'
		''***** rook legal moves ******
		'
		'
		FOR N = 5 TO 8
			FOR M = 1 TO 7
				'
				RkMove = Sq + Move_Offset(N) * M
				'

				'            IF (B(RkMove) = -99)  OR (B(RkMove) * Side > 0) OR (B(RkMove) * Side = -King) THEN
				'                M = 7
				'                GOTO r_m
				'            END IF
				'


				IF (B(RkMove) * Side > 0) THEN
					M = 7
					GOTO r_m
				END IF

				IF (B(RkMove) = -99) THEN
					M = 7
					GOTO r_m
				END IF


				IF (B(RkMove) * Side = -King) THEN
					M = 7
					GOTO r_m
				END IF


				IF B(RkMove) * Side < 0 THEN M = 7

				Pseu_Moves(depth) = Pseu_Moves(depth) + 1

				Move_List(Depth,Pseu_Moves(depth),1) = Sq: Move_List(Depth,Pseu_Moves(depth),2) = RkMove
				r_m:
			NEXT M
		NEXT N
		'
		Goto g_m_next

		m_g4:
		'
		'''***** king legal moves *****
		''
		''
		King_Proximity = 0	'adjacent kings flag
		''
		FOR M = 1 TO 8  'all possible king move directions
			''
			KingMove = Sq + Move_Offset(M) 'work out potential moves

			If B(KingMove) = -99  or B(KingMove) * Side > 0 then goto k_m

			For N = 1 to 8  ' loop to check whether kings are adjacent
				'
				If B(KingMove + Move_Offset(N)) = (Side * (-King)) then
					King_Proximity = 1  ' flag to exclude any such moves (ie adjacent squares)
					N = 8
				END IF
				''
			NEXT N
			'
			If King_Proximity = 0 Then
				Pseu_Moves(depth) = Pseu_Moves(depth) + 1
				Move_List(Depth,Pseu_Moves(depth),1) = Sq: Move_List(Depth,Pseu_Moves(depth),2) = KingMove
			ELSE 
				King_Proximity = 0
			END IF

			k_m:
		Next M
		''
		''
		'''**********************************
		'''next deal with castling options
		'''1 - White castle options
		'  need to build in castle flags still
		'''**********************************
		''
		IF Side = Black then goto b_cas

		if w_cas(1) <> 0 then goto w_cas

		if w_casflags(depth+2,1) <> 0 then goto w_cas

		If B(28) = 4 AND B(27) = 0 AND B(26) = 0 THEN
			Pseu_Moves(depth) = Pseu_Moves(depth) + 1
			Move_List(Depth,Pseu_Moves(depth),1) = 25: Move_List(Depth,Pseu_Moves(depth),2) = 27
		END IF


		w_cas:
		if w_cas(2) <> 0 then goto g_m_next

		if w_casflags(depth+2,2) <> 0 then goto g_m_next

		If B(21) = 4 AND B(22) = 0 AND B(23) = 0 AND B(24) = 0 THEN
			Pseu_Moves(depth) = Pseu_Moves(depth) + 1
			Move_List(Depth,Pseu_Moves(depth),1) = 25: Move_List(Depth,Pseu_Moves(depth),2) = 23
		END IF

		Goto g_m_next
		''
		'''**********************************
		'''2 - Black castle options
		'''**********************************
		''
		b_cas:
		''
		if b_cas(1) <> 0 then goto b_cas1

		IF b_casflags(depth+2,1) <> 0 then goto b_cas1  ' can't castle if king has already moved

		If B(98) = -4 AND B(97) = 0 AND B(96) = 0 THEN
			Pseu_Moves(depth) = Pseu_Moves(depth) + 1
			Move_List(Depth,Pseu_Moves(depth),1) = 95: Move_List(Depth,Pseu_Moves(depth),2) = 97
		END IF

		b_cas1:
		if b_cas(2) <> 0 then goto g_m_next

		if b_casflags(depth+2,2) <> 0 then goto g_m_next

		If B(91) = -4 AND B(92) = 0 AND B(93) = 0 AND B(94) = 0 THEN

			Pseu_Moves(depth) = Pseu_Moves(depth) + 1
			Move_List(Depth,Pseu_Moves(depth),1) = 95: Move_List(Depth,Pseu_Moves(depth),2) = 93
		END IF

		'' loop back to check next square
		g_m_next:


	Next Sq

	Return Pseu_Moves(depth)


end function

'///////////////////////////////////////////////////////////////////////////////







'///////////////////////////////////////////////////////////////////////////////
function incheck (side)

	'*******************************************************
	'               InCheck routine
	' method:
	'       1) Find king location
	'       2) For each piece trace move from K position
	'               to see if check is given
	'
	' InCheck routine (with adaptation) is based on code
	' written by Bill Rogers in his program Warlord X1b and
	' is used with his permission.
	'*******************************************************
	Check = True

	if side = white Then
		K = wkloc 
	Else
		K = bkloc
	EndIf

	IF Side = White Then
		PL = 1 
	Else
		PL = -1
	EndIf

	R = K

	'***********************************
	' test for check by pawn
	'***********************************
	K = K + PL * 9

	IF B(K) * Side = -Pawn THEN Return check'GOTO ck

	K = K + (PL * 2)

	IF B(K) * Side = -Pawn then Return check'GOTO ck

	'************************************
	'test for check by Knight
	'************************************
	K = R

	FOR N = 9 TO 16
		K = R
		K = K + Move_Offset(N)

		IF B(K) * Side = -Knight then
			N = 16
			Return check 'Goto ck
		END IF

	NEXT N
	K = R

	'************************************
	'test for check by Bishop / Queen
	'************************************
	FOR N = 1 TO 4
		FOR M = 1 TO 7

			K = K + Move_Offset(N)

			IF B(K) = 0 THEN goto Chk1

			IF B(K) = -99 THEN
				M = 7
				GOTO Chk1
			END IF

			IF B(K) * Side > 0 and (B(K) * Side <> 7) THEN
				M = 7
				GOTO Chk1
			END IF

			IF B(K) * Side = -Bishop OR B(K) * Side = -Queen then
				M = 7
				N = 4
				Return check'goto ck
			END IF

			IF B(K) * Side < 0 THEN  M = 7


			Chk1:
		NEXT M
		K = R
	NEXT N
	K = R

	'************************************
	'test for check by Rook / Queen
	'************************************
	FOR N = 5 TO 8
		FOR M = 1 TO 7

			K = K + Move_Offset(N)

			IF B(K) = 0 THEN goto Chk2

			IF B(K) = -99 THEN
				M = 7
				GOTO Chk2
			END IF

			IF B(K) * Side > 0 and (B(K) * Side <> 7) THEN
				M = 7
				GOTO Chk2
			END IF

			IF B(K) * Side = -Rook OR B(K) * Side = -Queen THEN
				M = 7
				N = 8
				Return check'goto ck
			END IF

			IF B(K) * Side < 0 THEN M = 7


			Chk2:
		NEXT M
		K = R
	NEXT N
	K = R

	Check = FALSE

	ck:
	Return check


end function


'///////////////////////////////////////////////////////////////////////////////

function attack(side,ps)

	attack_hit = True

	IF Side = White Then
		PL = 1 
	Else
		PL = -1
	EndIf

	R = ps

	'***********************************
	' test for check by pawn
	'***********************************
	ps = ps + PL * 9

	IF B(ps) * Side = -Pawn THEN Return attack_hit'GOTO ak

	ps = ps + (PL * 2)

	IF B(ps) * Side = -Pawn then Return attack_hit'GOTO ak

	'************************************
	'test for check by Knight
	'************************************
	ps = R

	FOR N = 9 TO 16
		ps = R
		ps = ps + Move_Offset(N)

		IF B(ps) * Side = -Knight then
			N = 16
			return attack_hit'Goto ak
		END IF

	NEXT N
	ps = R

	'************************************
	'test for check by Bishop / Queen
	'************************************
	FOR N = 1 TO 4
		FOR M = 1 TO 7

			ps = ps + Move_Offset(N)

			IF B(ps) = 0 then goto Atk1

			IF B(ps) = -99 THEN
				M = 7
				GOTO Atk1
			END IF

			IF B(ps) * Side > 0 and (B(ps) * Side <> 7) THEN
				M = 7
				GOTO Atk1
			END IF

			IF B(ps) * Side = -Bishop OR B(ps) * Side = -Queen then
				M = 7
				N = 4
				Return attack_hit'goto ak
			END IF

			IF B(ps) * Side < 0 THEN M = 7


			Atk1:
		NEXT M
		ps = R
	NEXT N
	ps = R

	'************************************
	'test for check by Rook / Queen
	'************************************
	FOR N = 5 TO 8
		FOR M = 1 TO 7

			ps = ps + Move_Offset(N)

			IF B(ps) = 0 then goto Atk2

			IF B(ps) = -99 THEN
				M = 7
				GOTO Atk2
			END IF

			IF B(ps) * Side > 0 and (B(ps) * Side <> 7) THEN
				M = 7
				GOTO Atk2
			END IF

			IF B(ps) * Side = -Rook OR B(ps) * Side = -Queen THEN
				M = 7
				N = 8
				Return attack_hit'goto ak
			END IF

			IF B(ps) * Side < 0 THEN M = 7


			Atk2:
		NEXT M
		ps = R
	NEXT N
	ps = R

	attack_hit = FALSE

	ak:
	Return attack_hit


end function

'-----------------------------------------------------------------
'function undo()
'
'Print "in undo"
'Print "side = ";side
'Print "undo "; move_hist(MoveNo,1); "- ";move_hist(MoveNo,2)
'
'if side = black then              ' update move history with current move
'     B(move_hist(MoveNo,1)) = B(move_hist(MoveNo,2))
'      B(move_hist(MoveNo,2)) = TB_piece
'      Print "B";move_hist(MoveNo,1); "=";B(move_hist(MoveNo,1)); " ";"B";move_hist(MoveNo,2);"=";TB_piece
'
'     move_hist(MoveNo,1) = 0
'     move_hist(MoveNo,2) = 0
'' elseif side = black then
''     move_hist(MoveNo,3) = B_M_From
''     move_hist(MoveNo,4) = B_M_To
'     end if
'
'
'
'end function




'-------------------------------------------------------------------
function clear_board()


	FOR ClrBd = 0 TO 119
		B(ClrBd) = -99
	NEXT ClrBd

	FOR X = 9 TO 2 STEP -1
		FOR Y = 1 TO 8
			B(X*10+Y) = 0
		NEXT Y
	NEXT X
	Function=0
End function




'----------------------------------------------------------------------------

function fen(O$)


	call clear_board()

	No_Pieces = 0: WQ = 0: BQ = 0:Mat_left = 0
	valid_fen = True
	fen_check = False
	b_king_no = 0:w_king_no = 0
	b_loc = 90:new_loc = 90 'a8
	a_h = 0: r_count = 0: f_ield = 0
	bpn = 0:wpn = 0
	bkloc = 0: wkloc = 0
	br = 0:wr = 0
	fmfen = 0:fmstring$ = ""
	mcfen = 0:mvstring$ = ""
	z = len(O$)



	FOR w = 10 to z


		num = val(mid(O$,w,1)) 'get number from string

		if f_ield > 3 and num <> 0 then goto e2

		if num <> 0 then
			new_loc = new_loc + num
			a_h = a_h + num
			goto n1
		end if

		pce$ = mid(O$,w,1)

		new_loc = new_loc + 1

		if f_ield <> 0 then goto e1

		if pce$ = "p" then
			No_Pieces = No_Pieces + 1
			B(new_loc) = -1
			bpn = bpn + 1 ' increment pawn counter
			if new_loc > 90 or new_loc < 29 then valid_fen = False   ' pawn can't be on 1/8th rank
		end if

		if pce$ = "b" then
			B(new_loc) = -3
			No_Pieces = No_Pieces + 1
			Bbp = Bbp + 1
			Mat_left = Mat_left + Bishop_Value
		end if
		if pce$ = "n" then
			B(new_loc) = -2
			No_Pieces = No_Pieces + 1
			Bkn = Bkn + 1
			Mat_left = Mat_left + Knight_Value
		end if
		if pce$ = "r" then
			B(new_loc) = -4
			No_Pieces = No_Pieces + 1
			br = br + 1
			Mat_left = Mat_left + Rook_Value
		end if
		if pce$ = "q" then
			B(new_loc) = -6
			No_Pieces = No_Pieces + 1
			BQ = BQ + 1
			Mat_left = Mat_left + Queen_Value
		END IF

		if pce$ = "P" then
			B(new_loc) = 1
			No_Pieces = No_Pieces + 1
			wpn = wpn + 1
			if new_loc > 90 or new_loc < 29 then valid_fen = False
		end if

		if pce$ = "B" then
			B(new_loc) = 3
			No_Pieces = No_Pieces + 1
			Wbp = Wbp + 1
			Mat_left = Mat_left + Bishop_Value
		END IF

		if pce$ = "N" then
			B(new_loc) = 2
			No_Pieces = No_Pieces + 1
			Wkn = Wkn + 1
			Mat_left = Mat_left + Knight_Value
		END IF

		if pce$ = "R" then
			B(new_loc) = 4
			No_Pieces = No_Pieces + 1
			wr = wr + 1
			Mat_left = Mat_left + Rook_Value
		end if

		if pce$ = "Q" then
			B(new_loc) = 6
			No_Pieces = No_Pieces + 1
			WQ = WQ + 1
			Mat_left = Mat_left + Queen_Value
		END IF

		if pce$ ="k" then
			b_king_no = b_king_no + 1
			No_Pieces = No_Pieces + 1
			bkloc = new_loc
			if b_king_no = 1 Then
				B(new_loc) = -7 
			Else
				valid_fen = False
			EndIf
		end if

		if pce$ ="K" then
			w_king_no = w_king_no + 1
			No_Pieces = No_Pieces + 1
			wkloc = new_loc
			if w_king_no = 1 Then
				B(new_loc) = 7 
			Else
				valid_fen = False
			EndIf
		end if



		if pce$ ="/" and a_h = 8 and r_count <= 7 then
			b_loc = b_loc - 10
			new_loc = b_loc
			a_h = -1
			r_count = r_count + 1
		elseif pce$ ="/" then valid_fen = False
		end if

		a_h = a_h + 1


		e1:
		if pce$ = " " then
			a_h = 0 'reset file counter if finished first field
			f_ield = f_ield + 1
			pce_last$ = pce$
			goto n1
		end if

		e2:
		if pce_last$ = " " and f_ield = 1 then
			if pce$ = "w" then side = white
			if pce$ = "b" then side = black
		elseif pce$ = " " and f_ield = 1 then valid_fen = False
		end if

		if pce_last$ = " " and f_ield = 2 then
			if pce$ = "K" then w_cas(1) = 99
			if pce$ = "Q" then w_cas(2) = 99
			if pce$ = "k" then b_cas(1) = 99
			if pce$ = "q" then b_cas(2) = 99
			if pce$ = "-" then
				w_cas(1) = -1
				w_cas(2) = -1
				b_cas(1) = -1
				b_cas(2) = -1
			end if
		end if

		if pce_last$ = " " and f_ield = 3 and pce$ = "-" then act_epsq = -1

		' need to build in ep square

		if (pce_last$ = " " and f_ield = 4) or (fmfen > 0 and f_ield = 4) then
			fmfen = fmfen + 1
			if fmfen = 1 then fmstring$ = str(num)
			if fmfen = 2 then fmstring$ = fmstring$ + str(num) ' only need to check 2 digits as > 99 is invalid
			fifty_move = val(fmstring$)
		end if
		'
		if pce_last$ = " " and f_ield = 5  or (mcfen > 0 and f_ield = 5) then
			mcfen = mcfen + 1
			if mcfen = 1 then mvstring$ = str(num)
			if mcfen = 2 then mvstring$ = mvstring$ + str(num)
			if mcfen = 3 then mvstring$ = mvstring$ + str(num)
			MoveNo = val(mvstring$)
			conv_clock_move_no = MoveNo
		end if
		'
		if a_h > 8 or f_ield > 5 then valid_fen = false

		n1:


	next w

	print "valid_fen = ";valid_fen

	If Mat_left < 2426 then endgame = 1

	' validation checks

	if w_cas(1) = 99 and (B(25) <> 7 OR B(28) <> 4) THEN valid_fen = false

	if w_cas(2) = 99 and (B(25) <> 7 OR B(21) <> 4) THEN valid_fen = false
	if b_cas(1) = 99 and (B(95) <> -7 OR B(98) <> -4) THEN valid_fen = false
	if b_cas(2) = 99 and (B(95) <> -7 OR B(91) <> -4) THEN valid_fen = false

	if w_cas(1) = 99 THEN w_cas(1) = 0
	if w_cas(2) = 99 THEN w_cas(2) = 0
	if b_cas(1) = 99 THEN b_cas(1) = 0
	if b_cas(2) = 99 THEN b_cas(2) = 0


	if bpn > 8 or wpn > 8 then valid_fen = false

	FOR K = 1 TO 8
		if bkloc - wkloc = Move_Offset(K) then valid_fen = false
	NEXT K


	if r_count <> 7 then valid_fen = False



	fen_check = incheck(-side)

	if fen_check = True then valid_fen = False


	if WinboardMode = 0 then Call display()


	If WinboardMode = 0 and valid_fen = False then
		print "Invalid fen - please re-enter"
	elseif WinboardMode = 1 and valid_fen = False then
		SendCommand("Illegal FEN - I'm not playing and I'm quitting!")
		end
	END IF

Function=0
end function




'-----------------------------------------------------------------------------

function display()

	'***************************************
	'           DisplayBoard
	'       Prints board to screen
	'***************************************

	If WinboardMode = 1 then return 0' skip if in winboard mode


	'***** if player is black then flip the board for display purposes *****
	If cmpclr = 1 THEN
		FOR I = 0 TO 119
			FlipBoard(119 - I) = B(I)
		NEXT

		FOR I = 0 TO 119
			B(I) = FlipBoard(I)
		NEXT
	END IF

	cmpclr$ = "B"  'Temp
	cls
	FOR d = 21 to 98
		if B(d) = -4 then u$(d) = "r"
		if B(d) = -3 then u$(d) = "b"
		if B(d) = -2 then u$(d) = "n"
		if B(d) = -6 then u$(d) = "q"
		if B(d) = -7 then u$(d) = "k"
		if B(d) = -1 then u$(d) = "p"
		if B(d) = 0 then u$(d) = "-"
		if B(d)= 4 then u$(d)="R"
		if B(d)= 3 then u$(d)="B"
		if B(d)= 2 then u$(d)="N"
		if B(d)= 6 then u$(d)="Q"
		if B(d)= 7 then u$(d)="K"
		if B(d)= 1 then u$(d)="P"
	NEXT d

	PRINT:Print

	FOR X = 9 TO 2 STEP -1
		FOR Y = 1 TO 8
			Print "   "; u$(X*10+Y) ;
			IF cmpclr = -1 and ((X*10+Y)=98 OR (X*10+Y)=88 or (X*10+Y)=78 OR (X*10+Y)=68 OR (X*10+Y)=58 OR (X*10+Y)=48 OR (X*10+Y)=38 OR (X*10+Y)=28 OR (X*10+Y)=18) THEN
				Print "   ***  "; X-1
				Print "   -----------------------------";
				print
			END IF

			If cmpclr = 1 and ((X*10+Y)=98 OR (X*10+Y)=88 or (X*10+Y)=78 OR (X*10+Y)=68 OR (X*10+Y)=58 OR (X*10+Y)=48 OR (X*10+Y)=38 OR (X*10+Y)=28 OR (X*10+Y)=18) THEN
				Print "   ***  "; ABS(X-10)
				Print "   -----------------------------";
				Print
			END IF

		NEXT Y
	NEXT X

	Print "   *********************************** "
	Print "   *********************************** "
	If cmpclr = -1 then
		Print "   "; "a   " ; "b   "; "c   "; "d   "; "e   ";"f   ";"g   ";"h   "
	else 
		Print "   "; "h   " ; "g   "; "f   "; "e   "; "d   ";"c   ";"b   ";"a   "
	END IF

	Print

	If cmpclr = -1 and BookHit = 1 then Print "NOmega's move... ";move_hist(MoveNo,3) ; "-";move_hist(MoveNo,4); " < Book move >"
	If cmpclr = 1 and BookHit = 1 then Print "NOmega's move... ";move_hist(MoveNo,1) ; "-";move_hist(MoveNo,2); " < Book move >"

	If MoveNo >= 1 and BookHit = 0 and cmpclr = 1 then Print "NOmega's move... ";move_hist(MoveNo,1) ; "-";move_hist(MoveNo,2); " Eval = "; best_score
	If MoveNo >= 1 and BookHit = 0 and cmpclr = -1 then Print "NOmega's move... ";move_hist(MoveNo,3) ; "-";move_hist(MoveNo,4); " Eval = "; best_score

	If MoveNo >= 1 and Bookhit = 1 and perft = false Then
		Print "Total nodes searched = 0" 
	Else
		Print "Total nodes searched = ";display_node
	EndIf
	Print:Print "---------------------------------------"
	If cmpclr = -1 Then
		Print "Move No: "; MoveNo + 1 
	Else
		Print "Move No: "; MoveNo
	EndIf
	'
	'
	''***** if player is black then re-flip the board *****
	If cmpclr = 1 THEN
		FOR I = 0 TO 119
			FlipBoard(119 - I) = B(I)
		NEXT
		FOR I = 0 TO 119
			B(I) = FlipBoard(I)
		NEXT
	END IF


end function



function ending()

	DO
		hitspace = getkey
	LOOP UNTIL hitspace = 32
	cls
	end
Function=0
end function


'-------------------------------------------------------------------------------


'*******************************************************
'The core winboard interface code is written by
'Tom McBurney and is used here with his permission
'Its integration and adaptation within NOmega is my own
'and any resulting errors are my responsibility
'several wb features are still to be implemented
'*******************************************************



'-------------------------------------------------------------------------------

function GetCommand() as string

	'This function will retrieve one command at a time from winboard.

	DIM sBuff AS STRING
	DIM iBytesRead AS INTEGER
	DIM iTotalBytes AS INTEGER
	DIM iAvailBytes AS INTEGER
	DIM iReturnCode AS INTEGER
	DIM sTemp AS STRING

	GetCommand = ""

	' Null character will make sBuff a C style empty string
	sBuff = CHR$(0)

	' PeekNamedPipe tells us if there is any data waiting to be retrieved.
	iReturnCode = PeekNamedPipe(InputHandle, BYVAL STRPTR(sBuff), 1, iBytesRead, iTotalBytes, iAvailBytes)

	' return empty string when there is no data to be retrieved.
	IF iTotalBytes = 0 THEN EXIT Function


	' Retrieve data
	DO
		iReturnCode = ReadFile(InputHandle, BYVAL StrPtr(sBuff), 1, iBytesRead, BYVAL 0&)
		IF ASC(sBuff) = 10 THEN EXIT DO    ' exit on line feed
		sTemp = sTemp + sBuff
	LOOP

	GetCommand = sTemp

END function


Function SendCommand(Byval sWBCmd As String) As integer

	'This function sends commands to Winboard

	DIM iBytesWritten AS INTEGER
	DIM iBytes AS INTEGER
	DIM iReturnCode AS INTEGER

	sWBCmd = sWBCmd + CHR$(10) ' add line feed to end of string

	iBytes = LEN(sWBCmd)
	iReturnCode = WriteFile(OutputHandle, BYVAL sWBCmd, iBytes, lBytesWritten, BYVAL 0&)

	SendCommand = 0

End Function

SUB WaitForWinboard
	' If we get 'xboard' command from Winboard then play in Winboard mode
	' or if we get a key stroke from a human then play in normal mode.

	DIM sKey AS STRING
	DIM sWBCommand AS STRING

	DO
		sKey = INKEY$
		SLEEP 100

		sWBCommand = GetCommand
		IF sWBCommand = "xboard" THEN
			WinboardMode = 1
			EXIT DO
		END IF

	LOOP UNTIL sKey <> ""

END SUB


'------------------------------------------------------------------------------



'''-------------------------------------------------------------------------------
''
function open_book()
''
'''**************************************************************
'''                       Opening book
'''method:
'''       routine scans board, saves current position in 'book$'
'''       and compares it to positions held in DATA statements
'''       therefore it can handle all book transpositions also.
'''       Choice of book move is determined by a random number
'''       (RD) which is compared to % value read from DATA which
'''       is held in variable (PC)
'''
'''       Book routine code, with minor adaptation was initially
'''       used by Bill Rogers in his program Warlord X1b and is
'''       used here with his permission.
'''**************************************************************
If perft = true then exit function

If side = white then MoveNo = MoveNo + 1
if winboardmode = 0 and cmpclr = 1 and MoveNo  = 0 then MoveNo = MoveNo + 1

BookHit = 0
RESTORE BookData


Bk1:
Book$ = "*"
N = 0

FOR X = 9 TO 2 STEP -1
	FOR Y = 1 TO 8
		IF B(X*10 + Y) = 0 THEN
			N = N + 1: GOTO Bk4
		END IF
		IF N = 0 GOTO Bk2
		N$ = STR$(N)
		Book$ = Book$ + RIGHT$(N$,LEN(N$))
		N = 0

		Bk2:
		I = B(X*10 + Y)

		IF I < 0 Then
			Book$ = Book$ + B$(I + 20) 
		Else
			Book$ = Book$ + B$(I)
		EndIf

		Bk4:
	NEXT 
NEXT 

N$ = STR$(MoveNo)
Book$ = Book$ + "*" + RIGHT$(N$, LEN(N$))

Bk5:
READ D$

IF side = white and D$ = "WHITE_END" OR side = black and D$ = "END" THEN GOTO Bk8

D12$ = LEFT$(D$, 1)

IF D12$ <> "*" GOTO Bk5
IF Book$ <> D$ GOTO Bk5

TP = 0
randomize
RD = (RND(1)*100)
BookHit = 1

Bk6:
READ D$, N$
D12$ = LEFT$(N$, 1)
IF D12$ = "*" GOTO Bk7
IF side = white and N$ = "WHITE_END" OR side = black and N$ = "END" THEN GOTO Bk7
PC = VAL(N$)
TP = TP + PC
IF RD > TP GOTO Bk6

Bk7:

'*** convert book move to correct co-ordinate format to enable move ***

X1$ = LEFT$(D$, 2)
X2$ = RIGHT$(D$, 2)

X1A$ = RIGHT$(X1$,1)
X1B$ = LEFT$(X1$,1)

X2A$ = RIGHT$(X2$,1)
X2B$ = LEFT$(X2$,1)

X1 = VAL(X1$)
X2 = VAL(X2$)

X1A = VAL(X1A$)
X1B = VAL(X1B$)

X2A = VAL(X2A$)
X2B = VAL(X2B$)

CompMoveFrom$ = (CHR(ASC(X1A$) + 48)) + (CHR(ASC(X1B$) - 1))
CompMoveTo$ = (CHR(ASC(X2A$) + 48)) + (CHR(ASC(X2B$) - 1))

If abs(B(X2)) = 6 then Mat_left = Mat_left - Queen_Value
If abs(B(X2)) = 4 then Mat_left = Mat_left - Rook_Value
If abs(B(X2)) = 3 then Mat_left = Mat_left - Bishop_Value
If abs(B(X2)) = 2 then Mat_left = Mat_left - Knight_Value


B(X2) = B(X1) ' make book move
B(X1) = 0


conv_clock_move_no = conv_clock_move_no + 1


IF X1 = 95 AND X2 = 97 THEN 'handle rook move when castling from book
	B(98) = 0
	B(96) = -4
	b_cas(1) = 1   'BlackBookCastle = 1  ' set castle flag
	b_cas(2) = -1  ' if castled O-O then can't later castle O-O-O! 'added 16/1/2010 - Leo castle bug
END IF

IF X1 = 25 AND X2 = 27 THEN 'handle rook move when castling from book
	B(28) = 0
	B(26) = 4
	w_cas(1) = 1
	w_cas(2) = -1  ' if castled O-O then can't later castle O-O-O! 'added 16/1/2010 - Leo castle bug
END IF


If (winboardmode = 1 and side = black) or (winboardmode = 0 and cmpclr = -1) then
	move_hist(MoveNo,3) = X1        'put moves into movelist
	move_hist(MoveNo,4) = X2
ElseIf (winboardmode = 1 and Side = White) or (winboardmode = 0 and cmpclr = 1) then
	move_hist(MoveNo,1) = X1
	move_hist(MoveNo,2) = X2
end if


IF WinboardMode = 1 THEN    'make book move if in winboard mode
	If Post = 1 then print 0;" ";0;" ";0;" ";0; " "; "<book move>: ";CompMoveFrom$ + CompMoveTo$
	SendCommand ("move " + lcase(CompMoveFrom$ + CompMoveTo$))
END IF


Bk8:

''-------------------------------------------------------------------------------



'////////////////////////////////////////////////////////////////////////

'White book moves
'1 - 1 d4/e4
'2 - 1 d4 d5 2 ..
'3 - 1 d4 d5 2 c4 e6 3...
'4 - 1 d4 d5 2 c4 e6 3 Nc3 Nf6 4...
'5 - 1 d4 d5 2 c4 e6 3 Nc3 Nf6 4 Bg5 Be7 5..
'5_1- 1 d4 d5 2 c4 e6 3 Nc3 Nf6 4 Bg5 Be7 5 Nf3 O-O 6...
'5_2- 1 d4 d5 2 c4 e6 3 Nc3 Nf6 4 Bg5 Be7 5 Nf3 O-O 6 Qc2 Ndb7 7...
'5_3- 1 d4 d5 2 c4 e6 3 Nc3 Nf6 4 Bg5 Be7 5 Nf3 O-O 6 Qc2 Ndb7 7 cd ed 8...
'5_4- 1 d4 d5 2 c4 e6 3 Nc3 Nf6 4 Bg5 Be7 5 Nf3 O-O 6 Qc2 h6   7...


'5a - 1 d4 d5 2 c4 e6 3 Nc3 Nf6 4 Bg5 Be7 5 e3 O-O 6...
'5b - 1 d4 d5 2 c4 e6 3 Nc3 Nf6 4 Bg5 Be7 5 e3 O-O 6 Nf3 h6 7...
'5c - 1 d4 d5 2 c4 e6 3 Nc3 Nf6 4 Bg5 Be7 5 e3 O-O 6 Nf3 h6 7 Bh4 b6 8...
'6 - 1 d4 d5 2 c4 e6 3 Nc3 Nf6 4 Bg5 Nbd7 5..
'6a - 1 d4 d5 2 c4 e6 3 Nc3 Nf6 4 Bg5 Nbd7 5 cd ed 6...
'6a1 - 1 d4 d5 2 c4 e6 3 Nc3 Nf6 4 Bg5 Nbd7 5 cd ed 6 Nf3 Qa5 7...
'6b - 1 d4 d5 2 c4 e6 3 Nc3 Nf6 4 Bg5 Nbd7 5 e3 c6 6...
'6c - 1 d4 d5 2 c4 e6 3 Nc3 Nf6 4 Bg5 Nbd7 5 e3 Be7 6...
'6d - 1 d4 d5 2 c4 e6 3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2 d4 Bb7 3 Bd3 e6 4 Nf3 c5 5 c3 Nf6 6...


'395 - 1 e4 g6 2..
'396 - 1 e4 g6 2 d4 Bg7 3 ..
'397 - 1 e4 g6 2 d4 Bg7 3 Nc3 d6 4...


'//////////////////////////////////////////////////////////////////////

'Black book moves

'1 - ' 1 d4...
'3 - ' 1 d4 d5  2 c4...
'5 - ' 1 d4 d5  2 c4 e6 3 Nc3...
'8 - ' 1 d4 d5  2 c4 e6 3 Nc3 Nf6  4 Bg5...
'15 -  1 d4 d5  2 c4 e6 3 Nc3 Nf6  4 Bg5 Be7 5 e3...
'18 -  1 d4 d5  2 c4 e6 3 Nc3 Nf6  4 Bg5 Be7 5 e3 0-0  6 Nf3...

'19 -  1 d4 d5  2 c4 e6 3 Nc3 Nf6  4 Bg5 Be7 5 e3 Nbd7 6 Nf3...
'19a -  1 d4 d5  2 c4 e6 3 Nc3 Nf6  4 Nf3 Be7 5 Bg5 ...


'29 -  1 d4 d5  2 c4 e6 3 Nc3 Nf6  4 cd ...
'29a -  1 d4 d5  2 c4 e6 3 Nc3 Nf6  4 cd ed  5 Bg5 ...
'29b -  1 d4 d5  2 c4 e6 3 Nc3 Nf6  4 cd ed  5 Bg5 Be7 6 e3....

'16 -  1 d4 d5  2 c4 e6 3 Nf3...

'9 - ' 1 d4 d5  2 c4 dc 3 e4....
'9a- ' 1 d4 d5  2 c4 dc 3 e4 c5 4 d5...
'9b- ' 1 d4 d5  2 c4 dc 3 e4 c5 4 d5 Nf6 5 Nc3...
'9c- ' 1 d4 d5  2 c4 dc 3 e4 c5 4 d5 Nf6 5 Nc3 b5 6 e5...
'9d- ' 1 d4 d5  2 c4 dc 3 e4 c5 4 d5 Nf6 5 Nc3 b5 6 e5 b4 7 ef...
'9e- ' 1 d4 d5  2 c4 dc 3 e4 c5 4 d5 Nf6 5 Nc3 b5 6 e5 b4 7 ef bc 8 bc...
'9m- ' 1 d4 d5  2 c4 dc 3 e4 c5 4 d5 Nf6 5 Nc3 b5 6 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
'702  - 1 g3 d5 2 Bg2...

'801  - 1 b3...
'802  - 1 b3 d5 2 Bb2 ...
'803  - 1 b3 e5 2 Bb2 ...

'805  - 1 a3...
'806  - 1 a4...
'807  - 1 c3...

'810  - 1 b4...
'811  - 1 b4 e5 2 Bb2...
'812  - 1 b4 e5 2 Bb2 Bxb4 3 Bxe5...
'813  - 1 b4 d5 2 Bb2...
'814  - 1 b4 d5 2 Bb2 Bg4 3 Nf3...
'815  - 1 b4 d5 2 Bb2 Qd6 3 a3..

'820  - 1 f4...
'821  - 1 f3...

'830  - 1 Nc3...
'831  - 1 Nc3 d5 2 e4..
'831a - 1 Nc3 d5 2 e4 de 3 Nxc3 ...
'831b - 1 Nc3 d5 2 e4 de 3 Nxc3 Bf5 4 Qf3 ..
'831c - 1 Nc3 d5 2 e4 de 3 Nxc3 Bf5 4 Ng3 ..


'835  - 1 Na3...
'837  - 1 Nh3...

'840 -  1 g4...
'841 -  1 g4 d5 2 Bg2..
'842 -  1 g4 d5 2 Bg2 c6 3 h3..

'843 -  1 g4 e5 2 Bg2..
'844 -  1 g4 e5 2 Bg2 d5 3 c4..

'850 -  1 e3...
'855 -  1 d3...

'860 -  1 h3...
'861 -  1 h4...
'------------------------------------------------------------------------------

'
'
If Side = White and BookHit = false then MoveNo = MoveNo - 1 'subtract moveno if no move has been played

return BookHit
'
end function


'-------------------------------------------------------------------------------

function help()

	'************************************
	'               HELP!
	'   Display help options - called by
	'   user typing 'help'
	'************************************

	cls
	Print "         *************************************************"
	Print "         *                    H E L P !!                   *"
	Print "         *                                                 *"
	Print "         *  save      - save game                          *"
	Print "         *  load      - load game                          *"
	Print "         *  perft     - run perft move generator test      *"
	print "         *  listgame  - show move list                     *"
	Print "         *  go        - make computer play                 *"
	Print "         *  level     - select level (search depth)        *"
	Print "         *  end       - exit                               *"
	Print "         *                                                 *"
	Print "         *             hit SPACE to continue               *"
	Print "         *************************************************"

	DO
		hitspace = getkey
	LOOP UNTIL hitspace = 32
	cls
Function=0
end function

'------------------------------------------------------------------------------
'
'
function SaveGame()

	'****************************************
	' Writes game details to 'SaveNOmega.DAT'
	' routine saves:
	'   - board position
	'   - move list
	'****************************************

	OPEN "O", 1, "SaveNomega.DAT"

	FOR X = 9 TO 2 STEP -1
		FOR Y = 1 TO 8
			WRITE #1, B(X*10 + Y)
		NEXT Y
		PRINT #1, " "
	NEXT X
	WRITE #1, MoveNo

	For f = 1 to MoveNo
		Write #1, move_hist(f,1),"-", move_hist(f,2), move_hist(f,3),"-", move_hist(f,4)
	next f

	PRINT #1, " "
	PRINT #1, "//////////////////////////////////////////"
	PRINT #1, " "

	FOR X = 9 TO 2 STEP -1
		FOR Y = 1 TO 8

			PRINT #1, "   "; u$(X*10+Y) ;

			IF ((X*10+Y)=98 OR (X*10+Y)=88 or (X*10+Y)=78 OR (X*10+Y)=68 OR (X*10+Y)=58 OR (X*10+Y)=48 OR (X*10+Y)=38 OR (X*10+Y)=28 OR (X*10+Y)=18) THEN
				PRINT #1, "   ***  "; X-1
				Print #1, "   -----------------------------";
				PRINT #1,
			END IF

		NEXT Y
	NEXT X

	PRINT #1, "   *********************************** "
	PRINT #1, "   *********************************** "

	PRINT #1, "   "; "a   " ; "b   "; "c   "; "d   "; "e   ";"f   ";"g   ";"h   "

	PRINT #1,
	PRINT #1,  "Move" ;"    "; "White";"      "; "Black"

	FOR f = 1 to MoveNo
		PRINT #1, f;"     "; move_hist(f,1); " -";move_hist(f,2);"    ";move_hist(f,3); " -";move_hist(f,4)
	NEXT f

	Close
	Function=0
End function

'-------------------------------------------------------------------------------

function LoadGame()

	'**************************************
	' Loads previously saved game
	' routine reads:
	'   - board position
	'   - move list
	' from 'SaveNOmega.DAT'
	'**************************************

	OPEN "I", 1, "SaveNomega.DAT"

	FOR X = 9 TO 2 STEP -1
		FOR Y = 1 TO 8
			INPUT #1, B(X*10 + Y)
		NEXT Y
	NEXT X

	Input #1, MoveNo

	FOR f = 1 TO MoveNo
		INPUT #1, move_hist(f,1),"-", move_hist(f,2), move_hist(f,3),"-", move_hist(f,4)
	NEXT f

	CLOSE
	CLS
Function=0
end function
'
''-------------------------------------------------------------------------------


BookData:

'****************************************************************
'                          BookData
' Data format:
' Board position/move no/book move/% choice/alternate book move
' note:    1) numbers relate to book lines below
'          2) additional book lines can be added with further
'             'Data' statements
'****************************************************************

'White book moves

DATA "*rnbqkbnrpppppppp32PPPPPPPPRNBQKBNR*1", "3454", "50", "3555" '1
DATA "*rnbqkbnrppp1pppp11p7P12PPP1PPPPRNBQKBNR*2", "3353", "50", "2746" '2
DATA "*rnbqkbnrppp2ppp4p6p6PP12PP2PPPPRNBQKBNR*3", "2243", "50", "2746" '3
DATA "*rnbqkb1rppp2ppp4pn5p6PP6N5PP2PPPPR1BQKBNR*4", "2367", "75", "5364" '4
DATA "*rnbqk2rppp1bppp4pn5p2B3PP6N5PP2PPPPR2QKBNR*5", "3545", "75", "2746" '5
DATA "*rnbq1rk1ppp1bppp4pn5p2B3PP6N2N2PP2PPPPR2QKB1R*6", "2433"  ' 5_1
DATA "*r1bq1rk1pppnbppp4pn5p2B3PP6N2N2PPQ1PPPPR3KB1R*7", "3545", "50", "5364" '5_2
DATA "*r1bq1rk1pppnbppp5n5p2B4P6N2N2PPQ1PPPPR3KB1R*8", "3545" ' 5_3
DATA "*rnbq1rk1ppp1bpp5pn1p3p2B3PP6N2N2PPQ1PPPPR3KB1R*7", "6758" ' 5_4

DATA "*rnbq1rk1ppp1bppp4pn5p2B3PP6N1P3PP3PPPR2QKBNR*6", "2746" '5a
DATA "*rnbq1rk1ppp1bpp5pn1p3p2B3PP6N1PN2PP3PPPR2QKB1R*7", "6758", "75", "6776" '5b
DATA "*rnbq1rk1p1p1bpp2p2pn1p3p6PP3B2N1PN2PP3PPPR2QKB1R*8", "2644" '5c
DATA "*r1bqkb1rpppn1ppp4pn5p2B3PP6N5PP2PPPPR2QKBNR*5", "5364", "50", "3545"'6
DATA "*r1bqkb1rpppn1ppp5n5p2B4P6N5PP2PPPPR2QKBNR*6", "3545" '6a
DATA "*r1b1kb1rpp1n1ppp2p1pn2q2p2B3PP6N1PN2PP3PPPR2QKB1R*7", "5364", "75", "4634" '6a1
DATA "*r1bqkb1rpp1n1ppp2p1pn5p2B3PP6N1P3PP3PPPR2QKBNR*6", "2746" '6b
DATA "*r1bqk2rpppnbppp4pn5p2B3PP6N1P3PP3PPPR2QKBNR*6", "2746" '6c
DATA "*r1bq1rk1pppnbppp4pn5p2B3PP6N1PN2PP3PPPR2QKB1R*7", "2644", "50", "5364" '6d
DATA "*r1bqk2rpppn1ppp4pn5p2B2bPP6N1P3PP3PPPR2QKBNR*6", "5364" '6e
DATA "*r1bqk2rpppn1ppp5n5p2B2b1P6N1P3PP3PPPR2QKBNR*7", "2644" '6f
DATA "*rnbqkbnrpp3ppp2p1p6p6PP6N5PP2PPPPR1BQKBNR*4", "3555" '7
DATA "*rnbqkbnrpp3ppp2p1p13PPp5N5PP3PPPR1BQKBNR*5", "4355" '7a
DATA "*rnbqk1nrpp3ppp2p1p6p5bPPP5N5PP3PPPR1BQKBNR*5", "5564" '7b
DATA "*rnbqk1nrpp3ppp2p8p5bPP6N5PP3PPPR1BQKBNR*6", "2746" '7c
DATA "*rnbqkb1rppp1pppp5n5p7P9N2PPP1PPPPRNBQKB1R*3", "3353", "50", "2367" '11
DATA "*rnbqkbnrppp2ppp4p6p7P9N2PPP1PPPPRNBQKB1R*3", "3353" '11a
DATA "*rnbqkb1rppp2ppp4pn5p2B4P9N2PPP1PPPPRN1QKB1R*4", "3545" '11b
DATA "*rn1qkb1rppp1pppp5n5p2B4P2b6N2PPP1PPPPRN1QKB1R*4", "3545" '11c
DATA "*rnbqkb1rppp1pppp11p2B4Pn8N2PPP1PPPPRN1QKB1R*4", "6758" '11d
DATA "*rnbqkb1rpp2pppp10pp7Pn2B5N2PPP1PPPPRN1QKB1R*5", "5463" '11d1
DATA "*r1bqkb1rpp2pppp2n7Pp8n2B5N2PPP1PPPPRN1QKB1R*6", "2234" '11d2
DATA "*r1bqkb1rpp2pppp2n7np11B5N2PPPNPPPPR2QKB1R*7", "3545" '11d3
DATA "*rnbqkb1rpp2pppp2p8p7Pn2B5N2PPP1PPPPRN1QKB1R*5", "3343" '11d7
DATA "*rnb1kb1rpp2pppp1qp8p7Pn2B2P2N2PP2PPPPRN1QKB1R*6", "2442" '11d8

DATA "*rnbqkbnrpp2pppp2p8p6PP12PP2PPPPRNBQKBNR*3", "2746" '13a
DATA "*rnbqkb1rpp2pppp2p2n5p6PP9N2PP2PPPPRNBQKB1R*4", "2243" '13b
DATA "*rnbqkb1rpp3ppp2p1pn5p6PP6N2N2PP2PPPPR1BQKB1R*5", "2367" '13c
DATA "*rnbqkb1rpp3ppp2p1pn8B3pP6N2N2PP2PPPPR2QKB1R*6", "3555" '13d
DATA "*rnbqkb1rpp2pppp2p2n12pP6N2N2PP2PPPPR1BQKB1R*5", "3151" '13p
DATA "*rn1qkb1rpp2pppp2p2n7b2P1pP6N2N3P2PPPPR1BQKB1R*6", "4665", "50", "4658" '13q

DATA "*rnbqkbnrppppp1pp13p5P12PPP1PPPPRNBQKBNR*2","2746" '17
DATA "*rnbqkb1rppppp1pp5n7p5P9N2PPP1PPPPRNBQKB1R*3", "2367" '17a
DATA "*rnbqkb1rpppp2pp4pn7pB4P9N2PPP1PPPPRN1QKB1R*4", "2234" '17b
DATA "*rnbqk2rppppb1pp4pn7pB4P9N2PPPNPPPPR2QKB1R*5", "6776", "75","3343" '17c
DATA "*rnbqkb1rppp3pp4pn5p1pB4P9N2PPPNPPPPR2QKB1R*5", "3545", "50", "3353" '17d
DATA "*rnbqkb1rppppp1pp13pB4Pn8N2PPP1PPPPRN1QKB1R*4", "6758", "50", "6756" '17e

DATA "*rnbqkbnrpppp1ppp4p14P12PPP1PPPPRNBQKBNR*2", "3353", "50", "3555" '21
DATA "*rnbqkbnrppp1pppp3p15P12PPP1PPPPRNBQKBNR*2", "3555" '22
DATA "*rnbqkb1rppp1pppp3p1n13PP11PPP2PPPRNBQKBNR*3", "2243" '22a
DATA "*rnbqkb1rppp1pp1p3p1np12PP5N5PPP2PPPR1BQKBNR*4", "2345", "50", "2367" '22b
DATA "*rnbqkb1rppp2ppp3p1n6p6PP5N5PPP2PPPR1BQKBNR*4", "2746" '22c
DATA "*rnbqkbnrppp1pppp18pP12PP2PPPPRNBQKBNR*3", "2746" '25
DATA "*rnbqkb1rppp1pppp5n12pP9N2PP2PPPPRNBQKB1R*4", "3545" '25a
DATA "*rnbqkb1rppp2ppp4pn12pP8PN2PP3PPPRNBQKB1R*5", "2653" '25b
DATA "*rnbqkbnr1pp1ppppp17pP9N2PP2PPPPRNBQKB1R*4", "3555" '25c
DATA "*rnbqkbnr2p1ppppp8p8pPP8N2PP3PPPRNBQKB1R*5", "3151" '25d
DATA "*rn1qkbnr1bp1ppppp8p6P1pPP8N3P3PPPRNBQKB1R*6", "5162" '25e
DATA "*rn1qkbnr1bp1pppp9p8pPP8N3P3PPPRNBQKB1R*7", "2191" '25f
DATA "*bn1qkbnr2p1pppp9p8pPP8N3P3PPP1NBQKB1R*8", "2243" '25g
DATA "*rnbqkbnrpp2pppp10p7pP9N2PP2PPPPRNBQKB1R*4", "5464" '25h
DATA "*rnbqkbnrpp3ppp4p5pP6p10N2PP2PPPPRNBQKB1R*5","2243" '25i
DATA "*rnbqkbnrpp3ppp10pp6p7N2N2PP2PPPPR1BQKB1R*6", "2464" '25j
DATA "*rnb1kbnrpp3ppp10pq6p7N2N2PP2PPPPR1B1KB1R*7", "4364" '25k
DATA "*rnbqkbnrppp2ppp11pp5PP12PP2PPPPRNBQKBNR*3", "5465" '26
DATA "*rnbqkbnrppp2ppp12P5Pp12PP2PPPPRNBQKBNR*4", "2746" '26a
DATA "*rnbqkb1rpppppppp5n13P12PPP1PPPPRNBQKBNR*2", "3353", "50", "2367" '31
DATA "*rnbqkb1rpppppppp14B4Pn11PPP1PPPPRN1QKBNR*3", "6756", "75", "6758" '33
DATA "*rnbqkb1rpp1ppppp10p8PnB10PPP1PPPPRN1QKBNR*4", "3545" '34
DATA "*rnb1kb1rpp1ppppp1q8pP8nB10PPP1PPPPRN1QKBNR*5", "2234" '34a
DATA "*rnb1kb1rpp1ppppp1q8pP9B10PPPnPPPPR2QKBNR*6", "5624" '34b
DATA "*rnb1kb1rpp1ppppp10pP20PqPBPPPPR2QKBNR*7", "3555" '34c
DATA "*rnb1kb1rpp1ppp1p6p3pP8P11PqPB1PPPR2QKBNR*8", "2122" '34c1
DATA "*rnb1kb1rpp1ppppp10pPq7P11P1PB1PPPR2QKBNR*8", "2644" '34c2
DATA "*rnbqkb1rpp2pppp3p6pP8nB10PPP1PPPPRN1QKBNR*5", "3646" '34d
DATA "*rnbqkb1rpp2pppp3p1n4pP9B7P2PPP1P1PPRN1QKBNR*6", "3555" '34e
DATA "*rnb1kb1rpp2pppp3p4q1pP8nB7P2PPP1P1PPRN1QKBNR*6", "2234" '34f
DATA "*rnbqkb1rppp1pppp11p7PnB10PPP1PPPPRN1QKBNR*4", "3545" '35
DATA "*rnbqkb1rpp2pppp10pp7PnB6P3PPP2PPPRN1QKBNR*5", "2644" '35a
DATA "*rnbqkb1rpp2pppp5n4pp7P1B5BP3PPP2PPPRN1QK1NR*6", "3343" '35b
DATA "*rnbqkb1rppp1pppp3p15PnB10PPP1PPPPRN1QKBNR*4", "2234" '36
DATA "*rnbqkb1rppp1pppp3p1n13P1B10PPPNPPPPR2QKBNR*5", "3555", "50", "3545" '36a
DATA "*rnbqkb1rpppp1ppp4p14PnB10PPP1PPPPRN1QKBNR*4", "2234", "50", "3646" '37
DATA "*rnbqkb1rpppp1ppp4pn13P1B7P2PPP1P1PPRN1QKBNR*5", "3555" '37a
DATA "*rnbqkb1rpppp1ppp4pn8B4P12PPP1PPPPRN1QKBNR*3", "3555" '38
DATA "*rnbqkb1rpppp1pp14pn1p6B4PP11PPP2PPPRN1QKBNR*4", "6776" '38a
DATA "*rnb1kb1rpppp1pp5pq1p11PP11PPP2PPPRN1QKBNR*5", "2746", "50", "2243" '38b
DATA "*rnb1kb1rppp2pp4ppq1p11PP8N2PPP2PPPRN1QKB1R*6", "2243" '38c
DATA "*rnbqk2rppppbppp4pn8B4PP11PPP2PPPRN1QKBNR*4", "2644" '38d
DATA "*rnbqk2rppp1bppp4pn5p2B4PP6B4PPP2PPPRN1QK1NR*5", "5565" '38e
DATA "*rnbqk2rppp1bppp4p6pP1B4Pn6B4PPP2PPPRN1QK1NR*6", "6785" '38e1
DATA "*rnb1k2rppp1qppp4p6pP6Pn6B4PPP2PPPRN1QK1NR*7", "3343" ' 38e2
DATA "*rnbqk2rpppnbppp4p6pP1B4P7B4PPP2PPPRN1QK1NR*6", "6785" '38e4
DATA "*rnb1k2rpppnqppp4p6pP6P7B4PPP2PPPRN1QK1NR*7", "3343", "50", "2143" ' 38e5

DATA "*rnbqk2rpp1pbppp4pn4p3B4PP6B4PPP2PPPRN1QK1NR*5", "5463", "50", "3343" '38f
DATA "*rnbqkb1rpp1p1ppp4pn4p3B4PP11PPP2PPPRN1QKBNR*4", "5464" '38g
DATA "*rnbqkb1rpp3ppp3ppn4pP2B5P11PPP2PPPRN1QKBNR*5", "2243" '38h
DATA "*rnbqk2rpp2bppp3ppn4pP2B5P5N5PPP2PPPR2QKBNR*6", "2662", "50", "2746" '38i
DATA "*rnbqkb1rppp1pppp5n5p2B4P12PPP1PPPPRN1QKBNR*3", "6776" '39
DATA "*rnbqkb1rppp2ppp5p5p7P12PPP1PPPPRN1QKBNR*4", "3545" '39a
DATA "*rnbqk2rppp2ppp3b1p5p7P8P3PPP2PPPRN1QKBNR*5", "3353" '39b
DATA "*rnbq1rk1ppp2ppp3b1p12BP8P3PP3PPPRN1QK1NR*7", "2746", "75", "2243" '39c
DATA "*rnbqkb1rpp3ppp2p2p5p7P8P3PPP2PPPRN1QKBNR *5", "2644" '39d
DATA "*rnbqk2rpp3ppp2pb1p5p7P7BP3PPP2PPPRN1QK1NR*6", "2735", "75", "2446" '39e
DATA "*rnbqkb1rppp1pp1p5p5p7P12PPP1PPPPRN1QKBNR*4", "3545", "50", "2746" '39f
DATA "*rnbqkb1rpp2pp1p5p4pp7P8P3PPP2PPPRN1QKBNR*5", "2746", "50", "2662" '39g
DATA "*rnbqkb1rpp1ppppp5n4p3B4P12PPP1PPPPRN1QKBNR*3", "6776", "50", "5464" '39h
DATA "*rnbqkb1rpp1ppp1p5p4p8P12PPP1PPPPRN1QKBNR*4", "5464" '39i
DATA "*rnb1kb1rpp1ppppp1q3n4pP2B17PPP1PPPPRN1QKBNR*4", "6776" '39j
DATA "*rnb1kb1rpp1ppp1p1q3p4pP20PPP1PPPPRN1QKBNR*5", "2423" '39k
DATA "*rnbqkb1rpppp1ppp4pn12PP12PP2PPPPRNBQKBNR*3", "2243", "75", "2746" '41
DATA "*rnbqkb1rppp2ppp4pn5p6PP9N2PP2PPPPRNBQKB1R*4", "2243", "50", "2367" '42
DATA "*rnbqkbnrpp3ppp2p1p6p6PP9N2PP2PPPPRNBQKB1R*4", "2433"  '43a
DATA "*rnbqkb1rpp3ppp2p1pn5p6PP9N2PPQ1PPPPRNB1KB1R*5", "2367" '43b
DATA "*rnbqkbnrpp3ppp4p5pp6PP9N2PP2PPPPRNBQKB1R*4", "5364" '43c
DATA "*rnbqkbnrpp3ppp10pp7P9N2PP2PPPPRNBQKB1R*5", "2243", "50", "2367" '43d
DATA "*rnbqk2rpppp1ppp4pn11bPP6N5PP2PPPPR1BQKBNR*4", "2442" , "50", "2433" '50
DATA "*rnbqk2rpp1p1ppp4pn4p6bPP5QN5PP2PPPPR1B1KBNR*5","5463", "80", "2746" '53
DATA "*r1bqk2rpp1p1ppp2n1pn4P6bP6QN5PP2PPPPR1B1KBNR*6", "2746", "50", "2367" '55
DATA "*rnbq1rk1pppp1ppp4pn11bPP6N5PPQ1PPPPR1B1KBNR*5", "2746" '60
DATA "*rnbqk2rpp1p1ppp4pn4p6bPP6N5PPQ1PPPPR1B1KBNR*5", "5463" '63
DATA "*rnbq1rk1pp1p1ppp4pn4P6bP7N5PPQ1PPPPR1B1KBNR*6","3141", "75", "2746" '64
DATA "*rnbqkb1rpppp1ppp5n6p5PP12PP2PPPPRNBQKBNR*3", "5465" '66
DATA "*rnbqkb1rpppp1ppp12P5P3n9PP2PPPPRNBQKBNR*4", "2356", "50", "2746" '66a
DATA "*r1bqkb1rpppp1ppp2n9P5P2Bn9PP2PPPPRN1QKBNR*5", "2746" '66b
DATA "*r1bqk2rpppp1ppp2n9P4bP2Bn6N2PP2PPPPRN1QKB1R*6", "2234" '66c
DATA "*r1b1k2rppppqppp2n9P4bP2Bn6N2PP1NPPPPR2QKB1R*7", "3545", "50", "3141" '66d
DATA "*rnbqk2rpppp1ppp12P4bP2Bn9PP2PPPPRN1QKBNR*5", "2234" '66e
DATA "*r1bqk2rpppp1ppp2n9P4bP2Bn9PP1NPPPPR2QKBNR*6", "2746" '66f
DATA "*rnbqk2rpppp1ppp10b1P5P3n6N2PP2PPPPRNBQKB1R*5", "3545" '66g
DATA "*r1bqk2rpppp1ppp2n7b1P5P3n5PN2PP3PPPRNBQKB1R*6", "2635" '66h
DATA "*r1bqk2rpppp1ppp2n7b1n5P9PN2PP2BPPPRNBQK2R*7", "4665", "50", "2243" '66i
DATA "*rnbqkb1rpppp1ppp12P5P1n11PP2PPPPRNBQKBNR*4", "2746", "50", "3141" '66j
DATA "*rnbqk2rpppp1ppp12P4bP1n8N2PP2PPPPRNBQKB1R*5", "2234" '66k
DATA "*r1bqk2rpppp1ppp2n9P4bP1n8N2PP1NPPPPR1BQKB1R*6", "3141" '66l
DATA "*r1bqkb1rpppp1ppp2n9P5P1n3P8P2PPPPRNBQKBNR*5", "2746" '66m
DATA "*r1bqkb1rppp2ppp2np8P5P1n3P4N3P2PPPPRNBQKB1R*6", "2433" '66n
DATA "*r2qkb1rppp2ppp2np8Pb4P1n3P4N3PQ1PPPPRNB1KB1R*7", "2243" '66o
DATA "*rnbqkb1rpppppp1p5np11PP12PP2PPPPRNBQKBNR*3", "2243", "50", "2746" '75
DATA "*rnbqk2rppppppbp5np11PP6N5PP2PPPPR1BQKBNR*4", "3555", "75", "2367" '77
DATA "*rnbqk2rppp1ppbp3p1np11PPP5N5PP3PPPR1BQKBNR*5", "2746", "75", "2635" '78
DATA "*rnbq1rk1ppp1ppbp3p1np11PPP5N2N2PP3PPPR1BQKB1R*6", "2635", "50", "2367" '80
DATA "*rnbq1rk1ppp1ppbp3p1np7B3PP6N2N2PP2PPPPR2QKB1R*6", "3545", "85", "3555" '83
DATA "*rnbq1rk1ppp1ppbp3p1np11PP1B4N2N2PP2PPPPR2QKB1R*6", "3545" '85
DATA "*rnbqkb1rppp1pp1p5np4p6PP6N5PP2PPPPR1BQKBNR*4", "5364" '86
DATA "*rnbqkb1rppp1pp1p6p4n7P6N5PP2PPPPR1BQKBNR*5", "2334" '86a
DATA "*rnbqk2rppp1ppbp6p4n7P6N5PP1BPPPPR2QKBNR*6", "3555", "50", "2746" '86b
DATA "*rnbqk2rppp1ppbp1n4p12PP5N5PP1B1PPPR2QKBNR*7", "3445" '86c
DATA "*rnbqkb1rppp1pp1p1n4p12P6N5PP1BPPPPR2QKBNR*6", "3467", "50", "2746" '86d

DATA "*rnbqkb1rpp1ppppp5n4p7PP12PP2PPPPRNBQKBNR*3", "5464" '88
DATA "*rnbqkb1rp2ppppp5n3ppP6P13PP2PPPPRNBQKBNR*4", "2746" '88a
DATA "*rnbqkb1rp2ppp1p5np2ppP6P10N2PP2PPPPRNBQKB1R*5", "2433" '88b
DATA "*rnbqkb1rp2ppp1p5np3pP6p10N2PPQ1PPPPRNB1KB1R*6", "3555" '88c
DATA "*rn1qkb1rpb1ppppp5n3ppP6P10N2PP2PPPPRNBQKB1R*5", "2433" '88g
DATA "*rn1qkb1rpb1ppppp5n4pP6p10N2PPQ1PPPPRNB1KB1R*6", "3555" '88h
DATA "*rn1qkb1rpb1p1ppp4pn4pP6p1P8N2PPQ2PPPRNB1KB1R*7", "2653" '88i
DATA "*rnbqkb1rp2ppppp5n4pP6p10N2PP2PPPPRNBQKB1R*5", "2243" '88k
DATA "*rnbqkb1rp3pppp3p1n4pP6p7N2N2PP2PPPPR1BQKB1R*6", "3555" '88l

DATA "*rnbqkb1rpp1p1ppp4pn4pP6P13PP2PPPPRNBQKBNR*4", "2746" '88t
DATA "*rnbqkb1rpp1p1ppp5n4pp6P10N2PP2PPPPRNBQKB1R*5", "5364" '88u
DATA "*rnbqkb1rpp3ppp3p1n4pP17N2PP2PPPPRNBQKB1R*6", "2243", "75", "3555"  '88v
DATA "*rnbqkb1rpp3p1p3p1np3pP14N2N2PP2PPPPR1BQKB1R*7", "2356", "50", "2367" '88w

DATA "*rnbqkbnrpppp1ppp12p7P11PPPP1PPPRNBQKBNR*2", "2746", "75", "2653" '101
DATA "*rnbqkb1rpppp1ppp5n6p5B1P11PPPP1PPPRNBQK1NR*3", "3444" '102
DATA "*r1bqkb1rpppp1ppp2n2n6p5B1P6P4PPP2PPPRNBQK1NR*4", "2746", "75", "2243" '103
DATA "*r1bqk2rppppbppp2n2n6p5B1P6P1N2PPP2PPPRNBQK2R*5", "2527" '104
DATA "*r1bq1rk1ppppbppp2n2n6p5B1P6P1N2PPP2PPPRNBQ1RK*6", "2625", "70", "5342" '105
DATA "*r1bqk2rpppp1ppp2n2n4b1p5B1P6P1N2PPP2PPPRNBQK2R*5", "2527", "75", "3343" '106
DATA "*r1bqk2rpppp1ppp2n2n6p4bB1P5NP4PPP2PPPR1BQK1NR*5", "2735", "75", "2746" '107
DATA "*rnbqkb1rpp1p1ppp2p2n6p5B1P6P4PPP2PPPRNBQK1NR*4", "2746" '108
DATA "*rnbqkb1rpp3ppp2p2n5pp5B1P6P1N2PPP2PPPRNBQK2R*5", "5342" '109
DATA "*rnbqkb1rpp3ppp2p2n6p7p4B1P1N2PPP2PPPRNBQK2R*6", "4667" '109a
DATA "*rnbqk2rpp1pbppp2p2n6p5B1P6P1N2PPP2PPPRNBQK2R*5", "2527" '110
DATA "*r1bqkbnrpppp1ppp2n9p7P8N2PPPP1PPPRNBQKB1R*3", "2653" '111
DATA "*r1bqkb1rpppp1ppp2n2n6p5B1P8N2PPPP1PPPRNBQK2R*4","3444", "75", "3454" ' 112
DATA "*r1bqk2rppppbppp2n2n6p5B1P6P1N2PPP2PPPRNBQK2R*5", "2527"  '114
DATA "*r1bqk2rppp2ppp2np1n4b1p5B1P6P1N2PPP2PPPRNBQ1RK*6", "3848" '115
DATA "*r1bq1rk1ppppbppp2n2n6p5B1P6P1N2PPP2PPPRNBQ1RK*6", "3848" '116
DATA "*r1bqk1nrpppp1ppp2n7b1p5B1P8N2PPPP1PPPRNBQK2R*4", "3343" '117
DATA "*r1bqk2rpppp1ppp2n2n4b1p5B1P5P2N2PP1P1PPPRNBQK2R*5", "3444" '118
DATA "*r1bqk2rppp2ppp2np1n4b1p5B1P5PP1N2PP3PPPRNBQK2R*6", "2527" '119
DATA "*r1bq1rk1ppp2ppp2np1n4b1p5B1P5PP1N2PP3PPPRNBQ1RK*7", "3848", "50", "2367" '120
DATA "*r1b1k1nrppppqppp2n7b1p5B1P5P2N2PP1P1PPPRNBQK2R*5", "2527" '121
DATA "*r1bqk1nrppp2ppp2np6b1p5B1P5P2N2PP1P1PPPRNBQK2R*5", "2527", "50", "3444" '122
DATA "*r1bqk2r1ppp1pppp1n2n4b1p5B1P5PP1N2PP3PPPRNBQK2R*6", "2527", "75", "5342" '123
DATA "*r1bqk2r1pp2pppp1np1n4b1p5B1P5PP1N2PP3PPPRNBQ1RK*7", "5342" '124
DATA "*rnbqkb1rpppp1ppp5n6p7P8N2PPPP1PPPRNBQKB1R*3", "3454" '124a
DATA "*rnbqkb1rpppp1ppp12p6Pn8N2PPP2PPPRNBQKB1R*4", "2644" '124b
DATA "*rnbqkb1rppp2ppp11pp6Pn6B1N2PPP2PPPRNBQK2R*5", "5465", "50", "4665" '124c
DATA "*rnbqkb1rpppp1ppp5n13pP8N2PPP2PPPRNBQKB1R*4", "5565", "50", "2653" '124f
DATA "*rnbqkb1rpppp1ppp12P6pn8N2PPP2PPPRNBQKB1R*5", "2454" '124g
DATA "*rnbqkb1rpppp1ppp18Bpn8N2PPP2PPPRNBQK2R*5", "2454" '124h
DATA "*rnbqkb1rpppp1ppp5n12BQ9N2PPP2PPPRNB1K2R*6", "2367" '124i

DATA "*rnbqkbnrpp1ppppp10p9P11PPPP1PPPRNBQKBNR*2", "2746", "75", "2243" '125
DATA "*rnbqkbnrpp2pppp3p6p9P8N2PPPP1PPPRNBQKB1R*3", "2662" '131
DATA "*rn1qkbnrpp1bpppp3p5Bp9P8N2PPPP1PPPRNBQK2R*4", "6284" '132
DATA "*rn2kbnrpp1qpppp3p6p9P8N2PPPP1PPPRNBQK2R*5", "2527" '133
DATA "*rn2kb1rpp1qpppp3p1n4p9P8N2PPPP1PPPRNBQ1RK*6", "5565" '134
DATA "*rn2kb1rpp1qpppp5n4p1p16N2PPPP1PPPRNBQ1RK*7", "4665" '135
DATA "*r2qkbnrpp1npppp3p6p9P8N2PPPP1PPPRNBQK2R*5", "2527" '137
DATA "*r2qkb1rpp1npppp3p1n4p9P8N2PPPP1PPPRNBQ1RK*6", "3444", "75", "2435" '138
DATA "*r2qkb1rpp1n1ppp3ppn4p9P6P1N2PPP2PPPRNBQ1RK*7", "2243" '139
DATA "*rnbqkbnrpp1p1ppp4p5p9P8N2PPPP1PPPRNBQKB1R*3", "2243" '139a
DATA "*rnbqkbnr1p1p1pppp3p5p9P5N2N2PPPP1PPPR1BQKB1R*4", "3454" '139b
DATA "*rnbqkbnr1p1p1pppp3p14pP5N2N2PPP2PPPR1BQKB1R*5", "4654" '139c
DATA "*rnb1kbnr1pqp1pppp3p14NP5N5PPP2PPPR1BQKB1R*6", "2644" '139d
DATA "*r1bqkbnrpp1p1ppp2n1p5p9P5N2N2PPPP1PPPR1BQKB1R*4", "3454", "50", "2662" '139e
DATA "*r1bqkbnrpp1p1ppp2n1p14pP5N2N2PPP2PPPR1BQKB1R*5", "4654" '139f
DATA "*r1b1kbnrppqp1ppp2n1p14NP5N5PPP2PPPR1BQKB1R*6", "2635" '139g
DATA "*r1bqkb1rpp1pnppp2n1p4Bp9P5N2N2PPPP1PPPR1BQK2R*5", "2527" '139h
DATA "*r1bqkb1r1p1pnpppp1n1p4Bp9P5N2N2PPPP1PPPR1BQ1RK*6", "6273" '139j
DATA "*r1bqkbnrpp1ppppp2n7p9P8N2PPPP1PPPRNBQKB1R*3", "2243", "50", "2653" '140
DATA "*r1bqkbnrpp1p1ppp2n1p5p9P5N2N2PPPP1PPPR1BQKB1R*3", "3454", "50", "2662" '145
DATA "*r1bqkbnrpp2pppp2np6p9P5N2N2PPPP1PPPR1BQKB1R*3", "3454", "50", "2662" '150
DATA "*r2qkb1rpp1bpppp2np1n3Bp9P5N2N2PPPP1PPPR1BQ1RK*5", "3454", "50", "3444" '156
DATA "*r1bqkbnrpp1ppppp2n7p9P5N5PPPP1PPPR1BQKBNR*3", "2662", "50", "2746" '180
DATA "*rnbqkbnrpp2pppp3p6p9P5N5PPPP1PPPR1BQKBNR*3", "2746" '181
DATA "*rnbqkb1rpp2pppp3p1n4p9P5N2N2PPPP1PPPR1BQKB1R*4", "3454" '181a
DATA "*rnbqkb1rpp2pppp3p1n13pP5N2N2PPP2PPPR1BQKB1R*5", "2454" '181b
DATA "*r1bqkb1rpp2pppp2np1n13QP5N2N2PPP2PPPR1B1KB1R*6", "2662" '181c
DATA "*rnbqkbnr1p2ppppp2p6p9P5N2N2PPPP1PPPR1BQKB1R*4", "3454" '182a
DATA "*rnbqkbnr1p2ppppp2p15pP5N2N2PPP2PPPR1BQKB1R*5", "4654" '182b
DATA "*rnbqkbnrpp1ppppp2p17P11PPPP1PPPRNBQKBNR*2", "2243", "50", "3353" '200
DATA "*rnbqkbnrpp2pppp2p8p8P5N5PPPP1PPPR1BQKBNR*3", "2746", "50", "3454" '220
DATA "*rn1qkbnrpp2pppp2p8p8P1b3N2N2PPPP1PPPR1BQKB1R*4", "3848", "50", "2635" '222
DATA "*rn1qkbnrpp3ppp2p1p6p8P5N2Q1PPPPP1PP1R1B1KB1R*6", "3454", "50", "2635" '223
DATA "*rn1qkbnrpp3ppp2p1p6p8P1b3N2N2PPPPBPPPR1BQK2R*5", "2527", "75", "3747" '224
DATA "*rn1qkb1rpp3ppp2p1pn5p8P1b3N2N2PPPPBPPPR1BQ1RK*6", "4665", "75", "3747" '225
DATA "*rnbqkbnrpp2pppp2p16Pp5N5PPP2PPPR1BQKBNR*4", "4355" '227
DATA "*rn1qkbnrpp2pppp2p10b5PN11PPP2PPPR1BQKBNR*5", "5547", "50", "5563" '228
DATA "*rnbqkbnrpp2pppp2p8p6P1P11PP1P1PPPRNBQKBNR*3", "5364", "50", "5564"  '230
DATA "*rnbqkbnrpp2pppp11p6P13PP1P1PPPRNBQKBNR*4", "5364" '231
DATA "*rnbqkbnrpp2pppp11p8P11PP1P1PPPRNBQKBNR*4", "5564" '232
DATA "*rnbqkb1rpp2pppp5n5P20PP1P1PPPRNBQKBNR*5", "2243", "50", "2662" '234
DATA "*rnbqkb1rpp2pppp11n14N5PP1P1PPPR1BQKBNR*6", "2653", "50", "2746" '236
DATA "*r1bqkb1rpp2pppp2n8n14N2N2PP1P1PPPR1BQKB1R*7", "3454", "50", "2662" '238
DATA "*r1bqkb1rpp1npppp5n3B1P20PP1P1PPPRNBQK1NR*6", "2243", "75", "2746" ' 245
DATA "*rnbqkb1rpppppppp5n14P11PPPP1PPPRNBQKBNR*2", "5565" '300
DATA "*rnbqkb1rpppppppp11nP19PPPP1PPPRNBQKBNR*3", "3454", "75", "2746" '301
DATA "*rnbqkb1rppp1pppp3p7nP16N2PPPP1PPPRNBQKB1R*4", "3454"'303
DATA "*rnbqkb1rppp1pppp3p7nP6P12PPP2PPPRNBQKBNR*4", "2746", "75", "3353" '305
DATA "*rn1qkb1rppp1pppp3p7nP6P2b6N2PPP2PPPRNBQKB1R*5", "2635" '307
DATA "*rnbqkbnrpppp1ppp4p15P11PPPP1PPPRNBQKBNR*2", "3454" '320
DATA "*rnbqkbnrppp2ppp4p6p7PP11PPP2PPPRNBQKBNR*3", "2243", "75", "5565" '322
DATA "*rnbqk1nrppp2ppp4p6p5b1PP5N5PPP2PPPR1BQKBNR*4", "5564", "50", "5565" '325
DATA "*rnbqk1nrppp2ppp11p5b1P6N5PPP2PPPR1BQKBNR*5", "2644" '330
DATA "*r1bqk1nrppp2ppp2n8p5b1P6NB4PPP2PPPR1BQK1NR*6", "3141", "50", "2735" '331
DATA "*rnbqk1nrpp3ppp4p5ppP4b1P6N5PPP2PPPR1BQKBNR*5", "3141" '335
DATA "*rnbqk1nrpp3ppp4p3b1ppP6P4P1N6PP2PPPR1BQKBNR*6", "3252" '337
DATA "*rnbqk1nrpp3ppp4p3b2pP4P1p4P1N7P2PPPR1BQKBNR*7", "4362" '338
DATA "*r1bqkbnrppp2ppp2n1p6p7PP5N5PPP2PPPR1BQKBNR*4", "5565" '339a
DATA "*r1bqkbnrppp3pp2n1pp5pP6P6N5PPP2PPPR1BQKBNR*5", "2662" '339b
DATA "*rnbqkbnrpp3ppp4p5ppP6P12PPP2PPPRNBQKBNR*4", "3343" '340
DATA "*r1bqkbnrpp3ppp2n1p5ppP6P6P5PP3PPPRNBQKBNR*5", "2746" '340a
DATA "*r1b1kbnrpp3ppp1qn1p5ppP6P6P2N2PP3PPPRNBQKB1R*6", "3141" '340b
DATA "*r2qkbnrpp1b1ppp2n1p5ppP6P6P2N2PP3PPPRNBQKB1R*6", "3141", "50", "2635" '340c

DATA "*r1bqkbnrpppppppp2n17P11PPPP1PPPRNBQKBNR*2", "2746" '350
DATA "*r1bqkbnrppp1pppp2np16P8N2PPPP1PPPRNBQKB1R*3", "3454" '351
DATA "*r1bqkb1rppp1pppp2np1n13PP8N2PPP2PPPRNBQKB1R*4", "2243", "75", "5464" '353
DATA "*r2qkb1rppp1pppp2np1n13PP1b3N2N2PPP2PPPR1BQKB1R*5", "2345", "75", "5464" '354
DATA "*rnbqkbnrppp1pppp11p8P11PPPP1PPPRNBQKBNR*2", "5564", "85", "2243" '360
DATA "*rnb1kbnrppp1pppp11q20PPPP1PPPRNBQKBNR*3", "2243", "80", "2746" '362
DATA "*rnb1kbnrppp1pppp8q17N5PPPP1PPPR1BQKBNR*4", "3454", "75", "2746" '364
DATA "*rnb1kb1rppp1pppp5n2q10P6N5PPP2PPPR1BQKBNR*5", "2746", "75", "2635" '366
DATA "*rnb1kb1rppp1pppp5n2q17N2N2PPPP1PPPR1BQKB1R*5", "3454", "75","2635" '368
DATA "*rnbqkbnrppp1pppp19pP5N5PPPP1PPPR1BQKBNR*3", "4335" '370
DATA "*rnbqkbnrppp2ppp12p6pP11PPPPNPPPR1BQKBNR*4", "3547" '371
DATA "*rnbqkbnrp1pppppp1p18P11PPPP1PPPRNBQKBNR*2", "3454" '390
DATA "*rn1qkbnrpbpppppp1p17PP11PPP2PPPRNBQKBNR*3", "2644" '391
DATA "*rn1qkbnrpbpp1ppp1p2p14PP6B4PPP2PPPRNBQK1NR*4", "2746", "50", "2735" '392
DATA "*rn1qkbnrpb1p1ppp1p2p5p8PP6B1N2PPP2PPPRNBQK2R*5", "3343" '393
DATA "*rn1qkb1rpb1p1ppp1p2pn4p8PP5PB1N2PP3PPPRNBQK2R*6", "2435" '394
DATA "*rnbqkbnrpppppp1p6p13P11PPPP1PPPRNBQKBNR*2", "3454" '395
DATA "*rnbqk1nrppppppbp6p12PP11PPP2PPPRNBQKBNR*3", "2243", "75", "2746" '396
DATA "*rnbqk1nrppp1ppbp3p2p12PP5N5PPP2PPPR1BQKBNR*4", "2345", "50", "2746" '397

DATA "WHITE_END"


'Black book moves

DATA "*rnbqkbnrpppppppp19P12PPP1PPPPRNBQKBNR*1","9776","50","8464"  ' 1
DATA "*rnbqkb1rpppppppp5n12PP12PP2PPPPRNBQKBNR*2","8575","50","8565" ' 2
DATA "*rnbqkbnrppp1pppp11p7PP11PPP2PPPRNBQKBNR*2", "6455" '290a
DATA "*rnbqkbnrppp1pppp19Pp5N5PPP2PPPR1BQKBNR*3", "8565" '290b
DATA "*rnbqkbnrppp2ppp12p6PN11PPP2PPPR1BQKBNR*4", "6554" '290c
DATA "*rnbqkbnrppp2ppp12p2Q3Pp5N5PPP2PPPR1B1KBNR*4", "9273" '290d
DATA "*rnbqkbnrppp1pppp11p6PP12PP2PPPPRNBQKBNR*2","8575","75","6453" '3
DATA "*rnbqkb1rpppp1ppp5n6P5P13PP2PPPPRNBQKBNR*3","7657"   ' 4
DATA "*rnbqkb1rpppp1ppp12P5P1P1n9PP3PPPRNBQKBNR*4", "5765" '4a
DATA "*rnbqkb1rpppp1ppp12n5P1PP10PP4PPRNBQKBNR*5", "6573" '4b
DATA "*rnbqkb1rpppp1ppp5n5Pp5P13PP2PPPPRNBQKBNR*3", "9663"  '2a
DATA "*rnbqk2rpppp1ppp5n4bPp5P7N5PP2PPPPR1BQKBNR*4", "8474" '2b
DATA "*rnbqkbnrppp2ppp4p6p6PP6N5PP2PPPPR1BQKBNR*3","9776", "75", "8373"  ' 5
DATA "*rnbqkb1rpppp1ppp4pn12PP6N5PP2PPPPR1BQKBNR*3","9652", "50","8464" '6
DATA "*rnbqk2rpppp1ppp4pn11bPP6N5PPQ1PPPPR1B1KBNR*4","9597" '7
DATA "*rnbq1rk1pppp1ppp4pn11bPP4P1N6PQ1PPPPR1B1KBNR*5", "5243"  '7a
DATA "*rnbq1rk1pppp1ppp4pn12PP4P1Q6P2PPPPR1B1KBNR*6", "8272" '7b
DATA "*rnbq1rk1p1pp1ppp1p2pn8B3PP4P1Q6P2PPPPR3KBNR*7", "9371", "50", "9382" '7c
DATA "*rnbq1rk1p1pp1ppp1p2pn12PP4P1Q2N3P2PPPPR1B1KB1R*7", "9382", "50", "7655" '7d
DATA "*rnbq1rk1p1pp1ppp1p2pn12PP4P1Q2P3P2P1PPR1B1KBNR*7", "8363", "50", "8464" '7e
DATA "*rnbqkb1rppp2ppp4pn5p2B3PP6N5PP2PPPPR2QKBNR*4", "9685", "50", "9284" '8
DATA "*rnbqkbnrppp1pppp18pPP11PP3PPPRNBQKBNR*3", "8565", "50", "8363" '9
DATA "*rnbqkbnrpp2pppp10pP6p1P11PP3PPPRNBQKBNR*4", "9776" '9a
DATA "*rnbqkb1rpp2pppp5n4pP6p1P5N5PP3PPPR1BQKBNR*5", "8262" '9b
DATA "*rnbqkb1rp3pppp5n3ppPP5p7N5PP3PPPR1BQKBNR*6", "6252" '9c
DATA "*rnbqkb1rp3pppp5P4pP5pp7N5PP3PPPR1BQKBNR*7", "5243" '9d
DATA "*rnbqkb1rp3pppp5P4pP6p7P5P4PPPR1BQKBNR*8", "9284" '9e
DATA "*rnbqkb1rp3pppp5n3ppP6p1PB4N5PP3PPPR2QKBNR*6", "8171", "75", "9371" '9m
DATA "*rnbqkb1r4ppppp4n3ppPP5p2B4N5PP3PPPR2QKBNR*7", "6252"  '9n
DATA "*rnbqkb1r4ppppp4P4pP5pp2B4N5PP3PPPR2QKBNR*8", "5243" '9o

DATA "*rnbqkb1rpppp1ppp12P5P3n6N2PP2PPPPRNBQKB1R*4", "9663", "50", "9273"   '10
DATA "*rnbqkb1rpppp1ppp12P5P2Bn9PP2PPPPRN1QKBNR*4", "9273" '10a
DATA "*r1bqkb1rpppp1ppp2n9P5P2Bn6N2PP2PPPPRN1QKB1R*5", "9652" '10b
DATA "*r1bqk2rpppp1ppp2n9P4bP2Bn6N2PP1NPPPPR2QKB1R*6", "9485" '10c
DATA "*r1b1k2rppppqppp2n9P4bP2Bn5PN2PP1N1PPPR2QKB1R*7", "5765" '10d
DATA "*r1b1k2rppppqppp2n9P4bP2Bn1P4N3P1NPPPPR2QKB1R*7", "7365", "50", "5765" '10e  ' changed from 7364 in 0.4_b2 - leo bug 4/10/09
DATA "*rnbqkb1rpppp1ppp4pn12PP9N2PP2PPPPRNBQKB1R*3", "8464", "50", "9652" '11
DATA "*rnbqkbnrppp2ppp12p5pPP8N2PP3PPPRNBQKB1R*4", "6554", "50", "9652" '12
DATA "*rnbqk2rpppp1ppp4pn11bPP9N2PP1BPPPPRN1QKB1R*4", "9485" '13
DATA "*rnb1k2rppppqppp4pn11bPP9NP1PP1BPP1PRN1QKB1R*5", "9273" '13a
DATA "*r1b1k2rppppqppp2n1pn11bPP9NP1PP1BPPBPRN1QK2R*6", "5234" '13b
DATA "*rnbqk2rpppp1ppp4pn11bPP9N2PP1NPPPPR1BQKB1R*4", "8272" '13c
DATA "*rnbqk2rp1pp1ppp1p2pn11bPP4P4N3P1NPPPPR1BQKB1R*5", "5234" '13d
DATA "*rnbqk2rp1pp1ppp1p2pn12PP4P4N3P1BPPPPR2QKB1R*6", "9382" '13e
DATA "*rnbqk2rp1pp1ppp1p2pn12PP4P4N3P1QPPPPR1B1KB1R*6", "9382" '13f
DATA "*rnbqk2rpppp1ppp4pn11bPP6N1P3PP3PPPR1BQKBNR*4", "9597" '14
DATA "*rnbq1rk1pppp1ppp4pn11bPP6NBP3PP3PPPR1BQK1NR*5", "8464" '14a
DATA "*rnbq1rk1ppp2ppp4pn5p5bPP6NBPN2PP3PPPR1BQK2R*6", "8272", "50", "8363" '14b
DATA "*rnbq1rk1pppp1ppp4pn11bPP6N1P3PP2NPPPR1BQKB1R*5", "8464" '14c
DATA "*rnbq1rk1ppp2ppp4pn5p5bPP4P1N1P4P2NPPPR1BQKB1R*6", "5285", "75", "5274" '14d
DATA "*rnbqk2rpppp1ppp4pn11bPP6N2N2PP2PPPPR1BQKB1R*4", "8464" '14e
DATA "*rnbqk2rppp2ppp4pn5p2B2bPP6N2N2PP2PPPPR2QKB1R*5", "6453" '14f
DATA "*rnbqk2rppp2ppp4pn8B2bpPP5N2N2PP3PPPR2QKB1R*6", "8363", "50", "8262" '14g
DATA "*rnbqk2rppp2ppp4pn5P5b1P6N2N2PP2PPPPR1BQKB1R*5", "7564" '14h
DATA "*rnbqk2rppp2ppp5n5p2B2b1P6N2N2PP2PPPPR2QKB1R*6", "8878", "50", "9597" '14i
DATA "*rnbqk2rppp2ppp4pn5p5bPP6N1PN2PP3PPPR1BQKB1R*5", "8363", "50", "9597" '14j
DATA "*rnbqk2rpp3ppp4pn4pp5bPP6NBPN2PP3PPPR1BQK2R*6", "6453", "50", "9597" '14k
DATA "*rnbqk2rppp2ppp4pn5p4QbPP6N2N2PP2PPPPR1B1KB1R*5", "9273" '14l
DATA "*r1bqk2rppp2ppp2n1pn5pN3QbPP6N5PP2PPPPR1B1KB1R*6", "9384" '14m
DATA "*rnbqk2rppp1bppp4pn5p2B3PP6N1P3PP3PPPR2QKBNR*5", "9597", "50", "9284" '15
DATA "*rnbqkbnrppp2ppp4p6p6PP9N2PP2PPPPRNBQKB1R*3", "9776", "50", "8373" '16
DATA "*rnbqk2rppp2ppp4pn5p5bPP6N1PN2PP3PPPR1BQKB1R*5", "9597", "50", "8363" '17
DATA "*rnbq1rk1ppp1bppp4pn5p2B3PP6N1PN2PP3PPPR2QKB1R*6", "8878", "50", "9284" '18
DATA "*r1bqk2rpppnbppp4pn5p2B3PP6N1PN2PP3PPPR2QKB1R*6", "9597" , "50", "8373" '19
DATA "*rnbqk2rppp1bppp4pn5p2B3PP6N2N2PP2PPPPR2QKB1R*5", "9597" , "50", "8878" '19a
DATA "*r1bqkb1rpppp1ppp2n9P5P3n3N2N2PP2PPPPR1BQKB1R*5", "5765", "75", "9663" '20
DATA "*r1bqkb1rpppp1ppp2n9N5P7N5PP2PPPPR1BQKB1R*6", "7365" '20_1
DATA "*r1bqkb1rpppp1ppp11Qn5P7N5PP2PPPPR1B1KB1R*7", "8474" '20_2
DATA "*r1bqkb1rpppp1ppp12n3Q1P7N5PP2PPPPR1B1KB1R *7", "9685" '20_3
DATA "*r1bqkb1rpppp1ppp12n5P7N1P3PP3PPPR1BQKB1R*7", "9652", "50", "8474" '20_4
DATA "*r1bqkb1rpppp1ppp12n5PQ6N5PP2PPPPR1B1KB1R*7", "8474" '20_5
DATA "*r1bqkb1rpppp1ppp2n9P5P2Bn6N2PP2PPPPRN1QKB1R*5", "9652" '20a
DATA "*r1bqk2rpppp1ppp2n9P4bP2Bn6N2PP1NPPPPR2QKB1R*6", "9485" '20b
DATA "*r1bqk2rpppp1ppp2n9P4bP2Bn3N2N2PP2PPPPR2QKB1R*6", "9485" '20b1
DATA "*r1b1k2rppppqppp2n8QP4bP2Bn3N2N2PP2PPPPR3KB1R*7", "5243", "50", "8676" '20b2
DATA "*r1b1k2rppppq1pp2n2P5Q5bP2Bn3N2N2PP2PPPPR3KB1R*8", "5776" '20b3
DATA "*r1b1k2rppppqppp2n8QP5P2Bn3P2N2P3PPPPR3KB1R*8", "8676" '20b4
DATA "*r1bqkb1rpppp1ppp2n9P5P3n5PN2PP3PPPRNBQKB1R*5", "5765" '20c
DATA "*rnbqk2rpppp1ppp10b1P5P3n5PN2PP3PPPRNBQKB1R*5", "9273" '20d
DATA "*rnbqkb1rpppp1ppp12P5PQ2n9PP2PPPPRNB1KBNR*4","8474" '20f
DATA "*r1bqkb1rpppp1ppp2n9P1B3P3n6N2PP2PPPPRN1QKB1R*5", "9685" '20x
DATA "*r1bqk2rppppbppp2n9P5P2Bn6N2PP2PPPPRN1QKB1R*6", "8552" '20y

DATA "*rnbqkb1rpppppppp5n13P9N2PPP1PPPPRNBQKB1R*2", "8575", "50", "8464" '21
DATA "*rnbqk1nrppp2ppp12p4bpPP8N2PP1B1PPPRN1QKB1R*5", "5234"  '22
DATA "*rnbqkb1rpppppppp5n8B4P12PPP1PPPPRN1QKBNR*2", "8464", "50", "8363" '24
DATA "*rnbqkb1rppp1pppp5B5p7P12PPP1PPPPRN1QKBNR*3", "8576" '24a
DATA "*rnbqkb1rppp2ppp5p5p7P8P3PPP2PPPRN1QKBNR*4", "9674", "50", "9685" '24b
DATA "*rnbqk2rppp2ppp3b1p5p6PP8P3PP3PPPRN1QKBNR*5", "6453" '24c
DATA "*rnbqkb1rppp1pppp5n5p2B4P8P3PPP2PPPRN1QKBNR*3", "8363" '25
DATA "*rnbqkb1rpp2pppp5B4pp7P8P3PPP2PPPRN1QKBNR*4", "8576", "50", "8776" ' 25a
DATA "*rnbqkb1rpp2pp1p5p4pp7P6P1P3PP3PPPRN1QKBNR*5", "9472" '25b
DATA "*rnbqkb1rpp2pppp5n4pp2B4P6P1P3PP3PPPRN1QKBNR*4", "9273", "50", "9472" '25c
DATA "*rnbqkb1rppp1pppp5n5p2B4P12PPPNPPPPR2QKBNR*3", "9273", "50", "9284" '25d
DATA "*rnbqkb1rpp1ppppp5n4p3B4P12PPP1PPPPRN1QKBNR*3", "8776" '26
DATA "*rnbqkb1rpp1ppp1p5p4pP20PPP1PPPPRN1QKBNR*4", "9472", "50", "9687" '26a
DATA "*rnb1kb1rpp1ppp1p1q3p4pP20PPP1PPPPRNQ1KBNR*5", "7666", "50", "9687" '26b
DATA "*rnbqkb1rpp1ppppp5n4pP2B17PPP1PPPPRN1QKBNR*3", "7655" '26c
DATA "*rnbqkb1rpp1ppppp10pP8nB10PPP1PPPPRN1QKBNR*4", "8474" '26d
DATA "*rnbqkb1rpp2pppp3p6pP8nB7P2PPP1P1PPRN1QKBNR*5", "5576", "50", "9461" '26e
DATA "*rnbqkb1rpp1ppppp10pP2B5n2P8PPP1PPP1RN1QKBNR*4","9472" '26f
DATA "*rnbqkb1rppp2ppp4pn5p6PP6N2N2PP2PPPPR1BQKB1R*4", "9685", "75", "9284" '23
DATA "*rnbqkb1rpppp1ppp4pn8B4P9N2PPP1PPPPRN1QKB1R*3", "8363" '23a

DATA "*rnbqkbnrppp1pppp18pP9N2PP2PPPPRNBQKB1R*3", "9776" '27
DATA "*rnbqkb1rppp1pppp5n12pP8PN2PP3PPPRNBQKB1R*4", "8575" '27a
DATA "*rnbqkb1rppp2ppp4pn12BP8PN2PP3PPPRNBQK2R*5", "8171" '27b
DATA "*rnbqkb1r1pp2pppp3pn12BP8PN2PP3PPPRNBQ1RK*6", "8262", "50", "8363" '27c
DATA "*rnbqkbnrppp1pppp18pP8P3PP3PPPRNBQKBNR*3", "9776" '28
DATA "*rnbqkb1rppp1pppp5n12BP8P3PP3PPPRNBQK1NR*4", "8575" '28a
DATA "*rnbqkb1rppp2ppp4pn5P7P6N5PP2PPPPR1BQKBNR*4", "7564" '29
DATA "*rnbqkb1rppp2ppp5n5p2B4P6N5PP2PPPPR2QKBNR*5", "9685" '29a
DATA "*rnbqk2rppp1bppp5n5p2B4P42N1P3PP3PPPR2QKBNR*6", "8373" '29b
DATA "*rnbqkbnrppp1pppp18pP8P3PP3PPPRNBQKBNR*3", "9776", "50", "8575" '30
DATA "*rnbqkbnrpppppppp18P13PP1PPPPPRNBQKBNR*1", "9776", "50", "8575" ' 201
DATA "*rnbqkbnrpppp1ppp4p13PP12PP2PPPPRNBQKBNR*2", "8464", "50", "9776" '202
DATA "*rnbqkbnrpppp1ppp4p13P11P1PP1PPP1PRNBQKBNR*2", "8464" '204a
DATA "*rnbqkbnrppp2ppp4p6p6P11P1PP1PPPBPRNBQK1NR*3", "9776", "50", "6453" '204b
DATA "*rnbqkb1rppp2ppp4pn5p6P10NP1PP1PPPBPRNBQK2R*4", "6453", "50", "6454" '204c
DATA "*rnbqkb1rpppp1ppp4pn12P7N2N2PP1PPPPPR1BQKB1R*3", "9652" '205a
DATA "*rnbqkbnrpppp1ppp4p13P7N5PP1PPPPPR1BQKBNR*2", "8464" '206
DATA "*rnbqkbnrppp2ppp4p6P14N5PP1PPPPPR1BQKBNR*3", "7564" '206a


DATA "*rnbqkb1rpppppppp5n12P7N5PP1PPPPPR1BQKBNR*2", "8575", "50", "8363" '203
DATA "*rnbqkbnrpppppppp29N2PPPPPPPPRNBQKB1R*1", "9776", "50", "8464" '301
DATA "*rnbqkbnrppp1pppp11p7P9N2PPP1PPPPRNBQKB1R*2", "9776"    '302
DATA "*rnbqkb1rppp1pppp5n5p6PP9N2PP2PPPPRNBQKB1R*3", "8575"  '303
DATA "*rnbqkbnrppp1pppp11p6P10N2PP1PPPPPRNBQKB1R*2", "6454" ' 304
DATA "*rnbqkbnrppp1pppp11p17NP1PPPPPP1PRNBQKB1R*2", "9357" '310
DATA "*rn1qkbnrppp1pppp11p10b6NP1PPPPPPBPRNBQK2R*3", "8575" '310a
DATA "*rn1qkbnrppp2ppp4p6p10b6NP1PPPPPPBPRNBQ1RK*4", "9284", "50", "9776" '310b
DATA "*rnbqkb1rpppppppp5n12P10N2PP1PPPPPRNBQKB1R*2", "8575"   '351


DATA "*rnbqkb1rpppppppp5n23NP1PPPPPP1PRNBQKB1R*2", "8464" '352a
DATA "*rnbqkb1rppp1pppp5n5p17NP1PPPPPPBPRNBQK2R*3", "8373" '352b
DATA "*rnbqkb1rpp2pppp2p2n5p17NP1PPPPPPBPRNBQ1RK*4", "9357" '352c

DATA "*rnbqkbnrpppppppp20P11PPPP1PPPRNBQKBNR*1", "8565", "50", "8373" '501
DATA "*rnbqkbnrpppp1ppp12p7P8N2PPPP1PPPRNBQKB1R*2", "9273", "80", "9776" '502
DATA "*rnbqkb1rpppp1ppp5n6N7P11PPPP1PPPRNBQKB1R*3", "8474" ' 503
DATA "*rnbqkb1rppp2ppp3p1n14P8N2PPPP1PPPRNBQKB1R*4", "7655" ' 504
DATA "*rnbqkb1rppp2ppp3p15Pn8N2PPP2PPPRNBQKB1R*5", "7464"'504a
DATA "*rnbqkb1rppp2ppp11p7Pn6B1N2PPP2PPPRNBQK2R*6", "9273", "50", "9685" '504b
DATA "*rnbqkb1rppp2ppp3p16n5N2N2PPPP1PPPR1BQKB1R*5", "5543", " 50", "5576" '504c
DATA "*rnbqkb1rppp2ppp3p22P2N2PPP2PPPR1BQKB1R*6", "9685", "50", "9273" '504d
DATA "*r1bqkb1rppp2ppp2np22P1BN2PPP2PPPR2QKB1R*7", "9685", "50", "9357" '504e
DATA "*rnbqk2rppp1bppp3p17B4P2N2PPP2PPPR2QKB1R*7", "9273", "50", "9597" '504f

DATA "*rnbqkb1rpppp1ppp5n6p6PP8N2PPP2PPPRNBQKB1R*3", "7655"  '510
DATA "*rnbqkb1rpppp1ppp12p6Pn6B1N2PPP2PPPRNBQK2R*4", "8464" '510a
DATA "*rnbqkb1rpppp1ppp5n6p5B1P8N2PPPP1PPPRNBQK2R*3", "9273" '510b
DATA "*rnbqkb1rpppp1ppp5n6p7P5N2N2PPPP1PPPR1BQKB1R*3", "9273" '510c
DATA "*r1bqkb1rpppp1ppp2n2n3B2p7P5N2N2PPPP1PPPR1BQK2R*4", "7354" '510d
DATA "*r1bqkb1rpppp1ppp2n2n6p6PP5N2N2PPP2PPPR1BQKB1R*4", "6554" '511
DATA "*r1bqkb1rpppp1ppp2n2n13NP5N5PPP2PPPR1BQKB1R*5", "9652" '511a
DATA "*r1bqk2rpppp1ppp2N2n11b2P5N5PPP2PPPR1BQKB1R*6", "8273" '511b
DATA "*r1bqkbnrpppp1ppp2n9p5B1P8N2PPPP1PPPRNBQK2R*3", "9776" '530
DATA "*r1bqkb1rpppp1ppp2n2n6p1N3B1P11PPPP1PPPRNBQK2R*4", "8464", "50", "9663" '531
DATA "*r1bqk2rpppp1Npp2n2n4b1p5B1P11PPPP1PPPRNBQK2R*5", "6336" '531a
DATA "*r1bqk2rpppp1Bpp2n2n4b1p1N5P11PPPP1PPPRNBQK2R*5", "9585" '531b
DATA "*r1bq3rppppk1pp2n2n4bBp1N5P11PPPP1PPPRNBQK2R*6", "8474", "50", "9896" '531c
DATA "*r1bq1r2ppppk1pp2n2n4bBp1N5P11PPPP1PPPRNBQ1RK*7", "8474", "50", "8878" '531d
DATA "*r1bqkbnrpppp1ppp2n6B2p7P8N2PPPP1PPPRNBQK2R*3", "8171" '550
DATA "*r1bqkbnr1ppp1pppp1B9p7P8N2PPPP1PPPRNBQK2R*4", "8473" '550a
DATA "*r1bqkbnr1pp2pppp1p9p7P8N2PPPP1PPPRNBQ1RK*5", "9674", "50", "9474" '550b
DATA "*r1bqk1nr1pp2pppp1pb8p6PP8N2PPP2PPPRNBQ1RK*6", "6554" '550c
DATA "*r1bqkbnr1ppp1pppp1n9p3B3P8N2PPPP1PPPRNBQK2R*4", "9776", "50", "8474" '551
DATA "*r1bqkbnr1pp2pppp1np8p3B3P5P2N2PP1P1PPPRNBQK2R*5", "8666" '551a
DATA "*r1bqkbnr1pp3ppp1np8pP2B9P2N2PP1P1PPPRNBQK2R*6", "9366" '551b
DATA "*r1bqkbnr1pp2pppp1np8p3B3P8N2PPPP1PPPRNBQ1RK*5", "9776" '551c
DATA "*2brkb3pp2pppp1np1n6p3B3P8N2PPPP1PPPRNBQR1K*6", "9357" '551d
DATA "*r1bqkb1r1ppp1pppp1n2n6p3B2PP8N2PPP2PPPRNBQK2R*5", "6554" '551g ' changed 16/1/2010 - bug found in 0.5pr by Leo in Div 5c test
DATA "*r1bqkb1r1ppp1pppp1n2n10B2pP8N2PPP2PPPRNBQ1RK*6", "9685" '551h
DATA "*r1bqkb1r1ppp1pppp1n2n6p3B3P6P1N2PPP2PPPRNBQK2R*5", "8474" '551i
DATA "*r1bqkb1r1pp2pppp1np1n6p3B3P5PP1N2PP3PPPRNBQK2R*6", "9384", "50", "9685" '551j
DATA "*r1bqk2r1pp1bpppp1np1n6p1B1B3P5PP1N2PP3PPPRN1QK2R*7", "9597" '551k
DATA "*r1bqkb1r1pp2pppp1np1n6p3B1P1P6P1N2PP3PPPRNBQK2R*6", "9685" '551l
DATA "*r1bqk2r1pp1bpppp1np1n6p3B1P1P5NP1N2PP3PPPR1BQK2R*7", "9597" '551m
DATA "*r1bqkb1r1ppp1pppp1n2n6p3B3P8N2PPPP1PPPRNBQ1RK*5", "9685", "50", "7655" '552
DATA "*r1bqkb1r1ppp1pppp1n9p3B2Pn8N2PPP2PPPRNBQ1RK*6", "8262", "50", "6554" '553
DATA "*r1bqkb1r1ppp1pppp1n13B2pn8N2PPP2PPPRNBQR1K*7", "8464" '553a
DATA "*r1bqkb1r2pp1pppp1n6p2p6Pn4B3N2PPP2PPPRNBQ1RK*7", "8464" '553b
DATA "*r1bqkb1r2p2pppp1n6p1pP7n4B3N2PPP2PPPRNBQ1RK*8", "9375" '553c
DATA "*r1bqk2r1pppbpppp1B2n6p7P8N2PPPP1PPPRNBQ1RK*6", "8473" '553f
DATA "*r1bqk2r1pppbpppp1n2n6p3B3P8N2PPPP1PPPRNBQR1K*6", "8262" '554
DATA "*r1bqk2r2ppbpppp1n2n3p2p7P4B3N2PPPP1PPPRNBQR1K*7", "8474", "50", "9597" '555
DATA "*r1bq1rk3ppbpppp1n2n3p2p7P4BP2N2PP1P1PPPRNBQR1K*8", "8464", "50", "8474" '556
DATA "*r1bqk2r2p1bpppp1np1n3p2p7P4BP2N2PP1P1PPPRNBQR1K*8", "9597" '557
DATA "*r1bqkbnr1pp2pppp1np8p3B3P5P2N2PP1P1PPPRNBQK2R*5", "9384", "50", "9776" '560
DATA "*r2qkbnr1ppb1pppp1np8p3B3P5P2N2PP1P1PPPRNBQ1RK*6", "9785", "50", "9776" '561
DATA "*r1bqkbnrpppp1ppp2n9p6PP8N2PPP2PPPRNBQKB1R*3", "6554" '568
DATA "*r1bqkbnrpppp1ppp2n16NP11PPP2PPPRNBQKB1R*4", "9652", "50", "9776" '568a
DATA "*r1bqk1nrpppp1ppp2n14b1NP5P5PP3PPPRNBQKB1R*5", "5263", "50", "5285" '568b
DATA "*r1bqk1nrpppp1ppp2N7b9P5P5PP3PPPRNBQKB1R*6", "8273" '568c
DATA "*r1bqk1nrp1pp1ppp2p7b9P5PB4PP3PPPRNBQK2R*7", "8474", "50", "9458" '568d
DATA "*r1bqk1nrp1pp1ppp2p7b9P5P5PP1N1PPPR1BQKB1R*7", "8474", "50", "9476" '568e
DATA "*r1bqkb1rpppp1ppp2N2n14P11PPP2PPPRNBQKB1R*5", "8273" '568f
DATA "*r1bqkb1rp1pp1ppp2p2n6P19PPP2PPPRNBQKB1R*6", "9485", "50", "7664" '568g
DATA "*r1bqkb1rpppp1ppp2n2n13NP5N5PPP2PPPR1BQKB1R*5", "9652", "50", "9663" ' 568h
DATA "*r1bqkb1rp1pp1ppp2p2n14P6B4PPP2PPPRNBQK2R*6", "8565", "50", "8575" '568i
DATA "*r1bqk2rpppp1ppp2N2n11b2P5N5PPP2PPPR1BQKB1R*6", "8273" ' 568j
DATA "*r1bqk1nrppppbppp2n15BNP5P5PP3PPPRNBQK2R*6", "8474" '568k
DATA "*r1bqk1nrppp1bppp2Np14B1P5P5PP3PPPRNBQK2R*7", "8273" '568k1
DATA "*r1bqk1nrppppbppp2n16NP5P1B3PP3PPPRN1QKB1R*6", "9776" '568k7

DATA "*r1bqk1nrppppbppp2N17P5P5PP3PPPRNBQKB1R*6", "8273" '568l
DATA "*r1bqk1nrp1ppbpp2p15B1P5P5PP3PPPRNBQK2R*7", "9776" '568m
DATA "*r1bqk2rp1ppbppp2p2n6P5B7P5PP3PPPRNBQK2R*8", "7655" '568n

DATA "*r1bqk1nrpppp1ppp2n7b8NP5P1B3PP3PPPRN1QKB1R*6", "6372" '568s

DATA "*r1bqk1nrpppp1ppp1bn10N6P5P1B3PP3PPPRN1QKB1R*7", "7245" '586t
DATA "*r1bqk1nrpppp1ppp2n17P5P1N3PP3PPPRN1QKB1R*8", "9785", "50", "7385" '586u
DATA "*r1bqk1nrpppp1ppp1bn16NP1Q3P1B3PP3PPPRN2KB1R*7", "9476" '586v
DATA "*r1bqk1nrpppp1ppp1bn15BNP5P1B3PP3PPPRN1QK2R*7", "7365", "50", "9776" '568w

DATA "*r1bqkbnrpppp1ppp2n9p7P5N2N2PPPP1PPPR1BQKB1R*3", "9776", "50", "9663" '569
DATA "*rnbqkbnrpppp1ppp12p6PP11PPP2PPPRNBQKBNR*2", "6554" '570
DATA "*rnbqkbnrpppp1ppp19QP11PPP2PPPRNB1KBNR*3", "9273" '570a
DATA "*rnbqkbnrpppp1ppp12p5B1P11PPPP1PPPRNBQK1NR*2", "9776" '573
DATA "*rnbqkb1rpppp1ppp5n6p5B1P6P4PPP2PPPRNBQK1NR*3", "9663" '573a
DATA "*rnbqk2rpppp1ppp5n4b1p5B1P6P1N2PPP2PPPRNBQK2R*4", "9273", "50", "9597" '573b
DATA "*rnbq1rk1pppp1ppp5n4b1N5B1P6P4PPP2PPPRNBQK2R*5", "8464" '573b1
DATA "*rnbq1rk1pppp1ppp5n4b1p5B1P6P1N2PPP2PPPRNBQ1RK*5", "8474" '573b2

DATA "*rnbqk2rpppp1ppp5n4b1p5B1P5NP4PPP2PPPR1BQK1NR*4", "8474" '573c
DATA "*rnbqkb1rpppp1ppp5n6p5BPP11PPP2PPPRNBQK1NR*3", "6554" '573d
DATA "*rnbqkb1rpppp1ppp5n12BpP8N2PPP2PPPRNBQK2R*4", "9273" '573e
DATA "*rnbqkb1rpppp1ppp5n6p5B1P5N5PPPP1PPPR1BQK1NR*3", "9273" '573f
DATA "*rnbqkbnrpppp1ppp12p7PP10PPPP2PPRNBQKBNR*2", "9663" '591
DATA "*rnbqk1nrpppp1ppp10b1p7PP7N2PPPP2PPRNBQKB1R*3", "8474", "50", "8464" '591a
DATA "*rnbqk1nrpppp1ppp10b1p7PP4N5PPPP2PPR1BQKBNR*3", "8474" '591b
DATA "*rnbqk1nrppp2ppp3p6b1p7PP4N5PPPP2PPR1BQKBNR*4", "9776" '591c
DATA "*rnbqkbnrpppp1ppp12p7P5N5PPPP1PPPR1BQKBNR*2", "9663" '592
DATA "*rnbqk1nrpppp1ppp10b1p7P5N2N2PPPP1PPPR1BQKB1R*3", "8474" '592a
DATA "*rnbqk1nrppp2ppp3p6b1p6PP5N2N2PPP2PPPR1BQKB1R*4", "6554" '592b
DATA "*rnbqk1nrppp2ppp3p6b8NP5N5PPP2PPPR1BQKB1R*5", "9776" '592c
DATA "*rnbqk1nrpppp1ppp10b1p5B1P5N5PPPP1PPPR1BQK1NR*3", "8474" '593
DATA "*rnbqk1nrppp2ppp3p6b1p5B1P5NP4PPP2PPPR1BQK1NR*4", "9776", "50", "9273" '593a
DATA "*rnbqkbnrpp1ppppp2p16PP11PPP2PPPRNBQKBNR*2", "8464" '601
DATA "*rnbqkbnrpp2pppp2p8p7PP5N5PPP2PPPR1BQKBNR*3", "6455" '602
DATA "*rnbqkbnrpp2pppp2p16PN11PPP2PPPR1BQKBNR*4", "9366", "50", "9776" '603
DATA "*rn1qkbnrpp2pppp2p10b5P10N1PPP2PPPR1BQKBNR*5", "6677" '604
DATA "*rn1qkbnrpp2pppp2p3b12P3P6N1PPP2PP1R1BQKBNR*6", "8878" '605
DATA "*rn1qkbnrpp2ppp3p3bp7P3P10N1PPP2PP1R1BQKBNR*7", "7788" '607
DATA "*rn1qkbnrpp2ppp3p3bp11P3P5NN1PPP2PP1R1BQKB1R*7", "8575", "50", "9776" '607a
DATA "*rn1qkb1rpp2ppp3p2nbp4N6P3P6N1PPP2PP1R1BQKB1R*8", "7788" '607b
DATA "*rn1qkb1rpp2ppp3p2nbp7P3P9NN1PPP2PP1R1BQKB1R*8", "7788" '607c
DATA "*rn1qkbnrpp3pp3p1p1bp4N6P3P6N1PPP2PP1R1BQKB1R*8", "7788" '607d
DATA "*rn1qkbnrpp3pp3p1p1bp7P3P9NN1PPP2PP1R1BQKB1R*8", "7788" '607e

DATA "*rn1qkbnrpp2pppp2p3b12P9NN1PPP2PPPR1BQKB1R*6", "9284", "75", "9776" '610
DATA "*rnbqkb1rpp2pppp2p2N13P12PPP2PPPR1BQKBNR*5", "8576" '620
DATA "*rnbqkb1rpp3ppp2p2p12BP12PPP2PPPR1BQK1NR*6", "9485" '620a
DATA "*rnb1kb1rpp2qppp2p2p12BP12PPP1QPPPR1B1K1NR*7", "9357", "50","9375" '620b
DATA "*rnbqkb1rpp3ppp2p2p13P6P5PP3PPPR1BQKBNR*6", "9375" '620c
DATA "*rnbqkb1rpp3ppp2p2p13P9N2PPP2PPPR1BQKB1R*6", "9375" '620d
DATA "*rnbqkb1rpp3ppp2p2p13P12PPP1BPPPR1BQK1NR*6", "9375" '620e

DATA "*rnbqkb1rpp2pppp2p2n13P10N1PPP2PPPR1BQKBNR*5", "7363" '621
DATA "*rnbqkb1rpp2pppp5n4p8P9NN1PPP2PPPR1BQKB1R*6", "9273", "50", "8575" '621a
DATA "*rnbqkb1rpp2pppp5n4p8P8B1N1PPP2PPPR2QKBNR*6", "6354", "50", "7657" '621b


DATA "*rnbqkbnrpp2pppp2p8pP6P12PPP2PPPRNBQKBNR*3", "9366" '630
DATA "*rn1qkbnrpp2pppp2p8pPb5P6N5PPP2PPPR1BQKBNR*4", "8575", "75", "9472" '631
DATA "*rn1qkbnrpp3ppp2p1p6pPb5P2P3N5PPP2P1PR1BQKBNR*5", "6677" '631a
DATA "*rn1qkbnrpp3ppp2p1p1b4pP6P2P3N5PPP1NP1PR1BQKB1R*6", "9458", "75", "9685" '631b
DATA "*rn2kbnrpp3ppp2p1p1b4pP6P1NPq2N5PPP2P1PR1BQKB1R*7", "9652" '631b1
DATA "*rn2kbnrpp3ppp2p1p1b4pP6P2Pq2N4PPPP1NP2R1BQKB1R*7", "9652" '631b2
DATA "*rn2kbnrpp3ppp2p1p1b4pP6P2Pq2N3N1PPP2P1PR1BQKB1R*7", "9652" '631b3

DATA "*rn1qk1nrpp2bppp2p1p1b4pP6P2P3N1B3PPP1NP1PR2QKB1R*7", "8567" '631c
DATA "*rn1qkbnrpp3ppp2p1p1b4pP6P2PP2N5PPP2P2R1BQKBNR*6", "8878", "50", "8868" ' 631c1
DATA "*rn1qkbnrpp3pp3p1p1bp3pP2P3P2P3N5PPP2P2R1BQKBNR*7", "7788" '631c2

DATA "*rn1qkbnrpp3ppp2p1p6pPb5P6NB4PPP2PPPR1BQK1NR*5", "6644" '631d
DATA "*rn1qkbnrpp3ppp2p1p6pPb5P6N2N2PPP2PPPR1BQKB1R*5", "7363", "50", "9284" '631e
DATA "*rn1qkbnrpp3ppp4p4BppPb5P6N2N2PPP2PPPR1BQK2R*6", "9273" '631e1
DATA "*r2qkbnrpp3ppp2n1p4BppPb5P6N2N2PPP2PPPR1BQ1RK*7", "9483", "50", "9472" '631e2

DATA "*rn1qkbnrpp2pppp2p8pPb5P2P9PPP2P1PRNBQKBNR*4", "6655", "50", "6684"'631f
DATA "*rn1qkbnrpp2pppp2p8pP6Pb1P6P2PPP4PRNBQKBNR*5", "5577" '631g
DATA "*rn1qkbnrpp2pppp2p3b4pP6P2PP5P2PPP5RNBQKBNR*6", "8868", "50", "8878" '631h
DATA "*rn1qkbnrpp2pppp2p8pPb5P9N2PPP2PPPRNBQKB1R*4", "8575", "50", "8878" '631i
DATA "*rn1qkbnrpp3ppp2p1p6pPb5P9N2PPP1BPPPRNBQK2R*5", "9284", "50", "9652" '631m
DATA "*rn1qkbnrpp2pppp2p8pPb5P12PPPN1PPPR1BQKBNR*4", "8575" '631p
DATA "*rn1qkbnrpp3ppp2p1p6pPb5P2P9PPPN1P1PR1BQKBNR*5", "6677" '631q
DATA "*rn1qkbnrpp3ppp2p1p1b4pP6P2PP8PPPN1P2R1BQKBNR*6", "8878", "50", "8868" '631r
DATA "*rn1qkbnrpp3ppp2p1p1b4pP6P2P9PPPNNP1PR1BQKB1R*6", "7363" '631t


DATA "*rn2kbnrpp2pppp1qp8pPb5P2P3N5PPP2P1PR1BQKBNR*5", "6684" '631x
DATA "*rn2kbnrpp1bpppp1qp8pP3N2P2P9PPP2P1PR1BQKBNR*6", "7283" ' 631x1
DATA "*rn2kbnrpp2pppp1qp8pPb5P6N2N2PPP2PPPR1BQKB1R*5", "8575" '631x5
DATA "*rn2kbnrpp3ppp1qp1p6pPb5P6N2N2PPP1BPPPR1BQK2R*6", "6657" '631x6
DATA "*rn2kbnrpp2pppp1qp8pPb5P6NB4PPP2PPPR1BQK1NR*5", "7254", "50", "6644" '631x7
DATA "*rn2kbnrpp2pppp1qp8pP6P6NQ4PPP2PPPR1B1K1NR*6", "8575" ' 631x8
DATA "*rn2kbnrpp3ppp1qp1p6pP6P6NQ4PPP1NPPPR1B1K2R*7", "9284" '631x9
DATA "*rn2kbnrpp2pppp2p8pPb5q6NB1N2PPP2PPPR1BQK2R*6", "5457" '631x10
DATA "*rn2kbnrpp2pppp2p8pPb8q3NB1N1PPPP2PP1R1BQK2R*7", "5768" '631x11

DATA "*rnbqkbnrpp2pppp2p8P7P12PPP2PPPRNBQKBNR*3", "7364" '632
DATA "*rnbqkbnrpp2pppp11p6PP12PP3PPPRNBQKBNR*4", "9776" '632a
DATA "*rnbqkb1rpp2pppp5n5p6PP6N5PP3PPPR1BQKBNR*5", "9273", "50", "8575" '632b
DATA "*rnbqkb1rpp3ppp4pn5p6PP6N2N2PP3PPPR1BQKB1R*6", "9685", "50", "9652" '632c
DATA "*rnbqkbnrpp2pppp11p7P7B4PPP2PPPRNBQK1NR*4", "9273" '633
DATA "*r1bqkbnrpp2pppp2n8p7P6PB4PP3PPPRNBQK1NR*5", "9483", "50", "9776" '633a
DATA "*rnbqkbnrpp2pppp2p8p7PP11PPPN1PPPR1BQKBNR*3", "6455" '635
DATA "*rnbqkbnrpp2pppp2p8p7PP8P2PPP3PPRNBQKBNR*3", "8575" '636
DATA "*rnbqkbnrpp3ppp2p1p6p7PP5N2P2PPP3PPR1BQKBNR*4", "9652" '636a

DATA "*rnbqkbnrpp1ppppp2p17P8N2PPPP1PPPRNBQKB1R*2", "8464" '639
DATA "*rnbqkbnrpp2pppp2p8p8P5N2N2PPPP1PPPR1BQKB1R*3", "9357" ' 639a
DATA "*rn1qkbnrpp2pppp2p8p8P1b3N2N1PPPPP1PP1R1BQKB1R*4", "5746", "50", "5768" '639b
DATA "*rn1qkbnrpp2pppp2p8p8P5N2Q1PPPPP1PP1R1B1KB1R*5", "8474", "50", "9776" '639c

DATA "*rnbqkbnrpp1ppppp2p17P5N5PPPP1PPPR1BQKBNR*2", "8464" '640
DATA "*rnbqkbnrpp2pppp2p8p8P5N2Q2PPPP1PPPR1B1KBNR*3", "6455" '640a
DATA "*rnbqkbnrpp2pppp2p17N8Q2PPPP1PPPR1B1KBNR*4", "9284" '640b
DATA "*r1bqkbnrpp1npppp2p16PN8Q2PPP2PPPR1B1KBNR*5", "9776", "50", "8476" '640c

DATA "*rnbqkbnrpppppppp30P1PPPPPP1PRNBQKBNR*1", "8464", "75", "9776" '701
DATA "*rnbqkbnrppp1pppp11p18P1PPPPPPBPRNBQK1NR*1", "9776", "50", "8565" '702
DATA "*rnbqkbnrpppppppp25P6P1PPPPPPRNBQKBNR*1", "8565", "50", "8464" '801
DATA "*rnbqkbnrppp1pppp11p13P6PBPPPPPPRN1QKBNR*2", "9776", "50", "9273" '802
DATA "*rnbqkbnrpppp1ppp12p12P6PBPPPPPPRN1QKBNR*2", "9273" '803
DATA "*rnbqkbnrpppppppp24P8PPPPPPPRNBQKBNR*1", "8565", "50", "8464" '805
DATA "*rnbqkbnrpppppppp16P16PPPPPPPRNBQKBNR*1", "8565", "50", "8464" '806
DATA "*rnbqkbnrpppppppp26P5PP1PPPPPRNBQKBNR*1", "8565", "50", "8464" '807
DATA "*rnbqkbnrpppppppp17P14P1PPPPPPRNBQKBNR*1", "8565", "50", "8464" '810
DATA "*rnbqkbnrpppp1ppp12p4P14PBPPPPPPRN1QKBNR*2", "9652" '811
DATA "*rnbqk1nrpppp1ppp12B4b14P1PPPPPPRN1QKBNR*3", "9776" '812
DATA "*rnbqkbnrppp1pppp11p5P14PBPPPPPPRN1QKBNR*2", "9474", "50", "9357" '813
DATA "*rn1qkbnrppp1pppp11p5P4b6N2PBPPPPPPRN1QKB1R*3", "5746" '814
DATA "*rnb1kbnrppp1pppp3q7p5P6P8BPPPPPPRN1QKBNR*3", "8575" '815

DATA "*rnbqkbnrpppppppp21P10PPPPP1PPRNBQKBNR*1", "8464", "75", "9776" ' 820
DATA "*rnbqkbnrpppppppp29P2PPPPP1PPRNBQKBNR*1", "8565", "50", "8464" '821
DATA "*rnbqkbnrpppppppp26N5PPPPPPPPR1BQKBNR*1", "8464" '830
DATA "*rnbqkbnrppp1pppp11p8P5N5PPPP1PPPR1BQKBNR*2", "6455" '831
DATA "*rnbqkbnrppp1pppp164N11PPPP1PPPR1BQKBNR*3", "9366" '831a
DATA "*rn1qkbnrppp1pppp13b6N8Q2PPPP1PPPR1B1KBNR*4", "6677" '831b
DATA "*rn1qkbnrppp1pppp13b16N1PPPP1PPPR1BQKBNR*4", "6677" '831c
DATA "*rnbqkbnrpppppppp24N7PPPPPPPPR1BQKBNR*1", "8464", "50", "8565" '835
DATA "*rnbqkbnrpppppppp31NPPPPPPPPRNBQKB1R*1", "8565", "50", "8464" '837
DATA "*rnbqkbnrpppppppp22P9PPPPPP1PRNBQKBNR*1", "8565", "50", "8464" '840
DATA "*rnbqkbnrppp1pppp11p10P9PPPPPPBPRNBQK1NR*2", "8373" '841
DATA "*rnbqkbnrpp2pppp2p8p10P8PPPPPPPB1RNBQK1NR *3", "8565" '842
DATA "*rnbqkbnrpppp1ppp12p9P9PPPPPPBPRNBQK1NR*2", "8464" '843
DATA "*rnbqkbnrppp2ppp11pp5P3P9PP1PPPBPRNBQK1NR*3", "6454", "50", "6453" '844
DATA "*rnbqkbnrpppppppp28P3PPPP1PPPRNBQKBNR*1", "8565", "50", "8464" '850
DATA "*rnbqkbnrpppppppp27P4PPP1PPPPRNBQKBNR*1", "8565", "50", "8464" '855
DATA "*rnbqkbnrpppppppp31PPPPPPPP1RNBQKBNR*1", "8565", "50", "8464" '860
DATA "*rnbqkbnrpppppppp23P8PPPPPPP1RNBQKBNR*1", "8565", "50", "8464" '861

DATA "END"












