Code: Select all
bozochess 2011.10.15 Copyright (C) 2011 by S. J. Edwards
bozochess ready
Checkmate: 15129
FiftyMoves: 19324
Insufficient: 56878
Repetition: 2535
Stalemate: 6134
bozochess done
Here's the repetition detection code:
Code: Select all
function poscountpriors(var pos: postype; limit: integer): integer;
var
result: integer;
count: integer;
spevnodeptr: spevnodeptrtype;
begin
with pos do
begin
result := 0; count := 0; spevnodeptr := spevnodetail;
while (result < limit) and (count < hmvc) and (spevnodeptr <> nil) do
begin
if odd(count) then if spevnodeptr^.spev.mphc = mphc then inc(result);
inc(count); spevnodeptr := spevnodeptr^.prev
end;
poscountpriors := result
end
end; { poscountpriors }
function posisrepeated(var pos: postype): boolean;
var
result: boolean;
begin
with pos do
begin
if hmvc < 4 then result := false else result := poscountpriors(pos, 1) = 1;
posisrepeated := result
end
end; { posisrepeated }
function posisrepetitiondraw(var pos: postype): boolean;
var
result: boolean;
begin
with pos do
begin
if hmvc < 8 then result := false else result := poscountpriors(pos, 2) = 2;
posisrepetitiondraw := result
end
end; { posisrepetitiondraw }