Bozo's move generation routine hierarchy starts with the PosGenerate routine that generates all legal moves in no particular order with no markings and no scores. From that, there are a series of meta-generation routines:
function PosIsMateIn1(var pos: postype): Boolean;
var
myresult: Boolean;
gms: gmstype;
index: gctype;
begin
with pos, gms do
begin
myresult := False;
PosGenOnlyChecks(pos, gms);
index := 0;
while (not myresult) and (index < movecount) do
begin
PosExecute(pos, moves[index]);
if PosIsCheckmate(pos) then
myresult := True;
PosRetract(pos);
Inc(index)
end
end;
PosIsMateIn1 := myresult
end; { PosIsMateIn1 }
function PosIsLoseIn1(var pos: postype): Boolean;
var
myresult: Boolean;
gms: gmstype;
index: gctype;
begin
with pos, gms do
begin
PosGenerate(pos, gms);
if movecount = 0 then
myresult := inch
else
begin
myresult := True;
index := 0;
while myresult and (index < movecount) do
begin
PosExecute(pos, moves[index]);
if not PosIsMateIn1(pos) then
myresult := False;
PosRetract(pos);
Inc(index)
end
end
end;
PosIsLoseIn1 := myresult
end; { PosIsLoseIn1 }
function PosIsMateIn2(var pos: postype): Boolean;
var
myresult: Boolean;
gms: gmstype;
index: gctype;
begin
with pos, gms do
begin
myresult := False;
index := 0;
PosGenerate(pos, gms);
PosMarkChecks(pos, gms);
GmsMoveChecksToFront(gms);
while (not myresult) and (index < movecount) do
begin
PosExecute(pos, moves[index]);
if PosIsLoseIn1(pos) then
myresult := True;
PosRetract(pos);
Inc(index)
end
end;
PosIsMateIn2 := myresult
end; { PosIsMateIn2 }
function PosIsLoseIn2(var pos: postype): Boolean;
var
myresult: Boolean;
gms: gmstype;
index: gctype;
begin
with pos, gms do
begin
PosGenerate(pos, gms);
if movecount = 0 then
myresult := inch
else
begin
myresult := True;
index := 0;
while myresult and (index < movecount) do
begin
PosExecute(pos, moves[index]);
if not PosIsMateIn2(pos) then
myresult := False;
PosRetract(pos);
Inc(index)
end
end
end;
PosIsLoseIn2 := myresult
end; { PosIsLoseIn2 }
function PosIsMateIn3(var pos: postype): Boolean;
var
myresult: Boolean;
gms: gmstype;
index: gctype;
begin
with pos, gms do
begin
myresult := False;
index := 0;
PosGenerate(pos, gms);
PosMarkChecks(pos, gms);
GmsMoveChecksToFront(gms);
while (not myresult) and (index < movecount) do
begin
PosExecute(pos, moves[index]);
if PosIsLoseIn2(pos) then
myresult := True;
PosRetract(pos);
Inc(index)
end
end;
PosIsMateIn3 := myresult
end; { PosIsMateIn3 }
As mentioned in another thread, I've converted Bozo's checkmate search from a recursive scheme to an iterative, state driven scheme. I'm using the new checkmate search as a model for a general move search that is now being coded. I hope to have this ready soon.
The parsers for EPD and for PGN are also under development.
I connected the FEN file reader code to the program's mate finder and got the ffmate command which reads a file of FEN records and runs the mate finder to fixed depth on each one.
The main goals are verification and performance testing of the mate finder code. I have a set of four FEN files each with 100,000 records for mate in 1 up to 4 moves. The program solves a mate in 3 with a mean of 5 milliseconds, and a mate in 4 is solved with a mean of 43 milliseconds. The mate in 1 and mate in 2 problems are solved too quickly under millisecond resolution to get accurate timing results.
Bozo's first game was played with a full width depth limit of only one ply with a very simple evaluation function and a simple quiescence search. The code is non-recursive, like the program's mate finder. The astonishing fact is that the search code, on its very first run, did not hang.
I recently ran Bozo on my 100,000 position matein4.fen file. The mean time per position, including all overhead, was 37.3 milliseconds. The position requiring the most search nodes (578,950) was:
[d]1rb5/2pk3p/1p3Qpn/pP1pp1N1/3B4/1P1B4/3bK1PP/2R3NR w - - 8 42[/d]
The solution for the above is: 42 Ne6 Bxc1 43 Ng7 exd4 44 Qe6+ Kd8 45 Qe8#
The current command set now includes option manipulation. An option is a boolean value with a handy four character name mich is used to contral program operation.
Not all commands are implemented at this time.
Most of the current effort is on move ordering issues.
[] help
Enter a command, or a sequence of one or more SAN chess moves
Commands:
bench Run the benchmark
d Display everything
dao Display active options
db Display board (ANSI color)
dbbdb Display bitboard database
dbmono Display board (monochrome)
dfen Display FEN
dm Display moves
dp Display position
dpgn Display PGN
dpi Display program identification
echo Echo parameters
efnormal Normalize from an EPD <input-file> to an EPD <output-file>
exit Exit program
ffmate Scan FEN <input-file> data, find mate in <number> full moves
ffnormal Normalize from a FEN <input-file> to a FEN <output-file>
ffperft Summing over a FEN <input-file> data, run perft to <depth>
g Search for a move and then play it
gg Play both sides until the end of the game
help Show help
loadfen Load FEN from an <input-file>
loadpgn Load PGN from an <input-file>
mate Search for a checkmate in <number> full moves
new New game
noop No operation
optreset Reset <option> [<option>]*
optset Set <option> [<option>]*
perftbulk Run perft to <depth> with bulk counting
perftfull Run perft to <depth> with each node visited
perfttran Run perft to <depth> with transposition help
pfnormal Normalize from a PGN <input-file> to a PGN <output-file>
rg Generate and display a single random game
rgdump Dump to a PGN <output-file> <number> random games
rgstat Generate a report for <number> random game(s)
rm Retract move
rmp Retract move pair
s Search for a move but do not play it
savefen Save FEN to an <output-file>
savepgn Save PGN to an <output-file>
selftest Run the self test
sfen Set FEN <mpd> <good> <cavs> <epsq> <hmvc> <fmvn>
stag Set PGN <tagname> to <tagvalue>
test Run developer test
Options:
adcc Auto display: chess clock
adcp Auto display: chess position
trcv Trace: current variation
trea Trace: EPD analysis
trfd Trace: First time node at depth
trit Trace: iteration start/finish
trpv Trace: predicted variation
trts Trace: timing statistics