Article View: gnu.chess
Article #5110Fix for repetition detection
From: Chua Kong Sian
Date: Sun, 13 Feb 1994 09:24
Date: Sun, 13 Feb 1994 09:24
162 lines
4957 bytes
4957 bytes
I have the following changes to the repetition code detection which I've
tested with a couple of test positions. There are quite a number of
places which have to be changed, so it can get a bit confusing. I'll
try and simplify it by breaking up into different pieces.
1. First change is to repetition() in search.c. There is a line which
goes like this.
if (GameCnt > Game50 + 4)
Change this to
if (GameCnt > Game50 + 3)
2. Next change is in search(). There is a portion near the top that
looks like the following.
if ((ply <= Sdepth + 3) && rpthash[side][hashkey & 0xFF] > 0)
{
..
..
..
else
*rpt = 0;
Replace this with the following.
if (rpthash[side][hashkey & 0xFF] > 0)
{
*rpt = repetition ();
if (*rpt == 1)
score = 0;
else if (*rpt == 2)
{
bstline[ply] = 0;
return (0);
}
}
else
*rpt = 0;
3. The next change is in search(), slightly further down, where search
extensions are being determined. Replace the following..
else
{
if (score >= alpha &&
(InChk || (ply>1 && PawnThreat[ply - 1] ....
..
..
..
depth= 1;
ext++;
Threat[ply]= threat= 1;
}
with the following.
else
{
int tripple_check = 0;
if (score >= alpha &&
(InChk || (ply>1 && PawnThreat[ply - 1] && depth<DepthBeyond-4)
|| (hung[side] > 1 && !ext))) {
threat2= 1;
ext++;
depth= 1;
}
else if (score <= beta &&
((ply<Sdepth+4 && ply>4 &&
ChkFlag[ply-2] && ChkFlag[ply-4] &&
(ChkFlag[ply-2] != ChkFlag[ply-4] ||
(flag.threat && DOTHREAT && QueenCheck[ply-2])))
||
(flag.threat && ply<DepthBeyond-DEPTHMARGIN && ply>6
&& ChkFlag[ply-2] && ChkFlag[ply-4] && ChkFlag[ply-6]
&& (tripple_check=1)
&& ((ply < Sdepth+4 ?
(ChkFlag[ply-2] != ChkFlag[ply-4] || ChkFlag[ply-2] !=
ChkFlag [ply-6])
: (ChkFlag[ply-2] != ChkFlag[ply-4] &&
ChkFlag[ply-2] != ChkFlag[ply-6] &&
ChkFlag[ply-4] != ChkFlag[ply-6]))
|| (DOTHREAT && QueenCheck[ply-2]
&& QueenCheck[ply-4] && QueenCheck[ply-6]
&& QueenCheck[ply-2] != QueenCheck[ply-6]))
))) {
if (tripple_check && DepthBeyond < Sdepth+13+DEPTHMARGIN)
{
extdb += 2;
DepthBeyond += 2;
}
depth= 1;
ext++;
Threat[ply]= threat= 1;
}
Note: The tripple_check idea comes from TomV.
4. The last important change is made deep within search().
Look for
else if (rcnt == 1) node->score /= 2;
and replace this with
else if (rcnt == 1) node->score = 0;
The effects of the new changes can be tried against the following 2 test
positions where perpetual check is the theme.
White computer Black Human 1 eps 0 # To move Black correct f8f2
Castled White false Black false # ep
TimeControl 0 Operator Time 0
White Clock 6000 Moves 1
Black Clock 6000 Moves 1
0 .....R.. 10 10 10 10 10 10 10 10
1 ....q.BK 10 10 10 10 10 10 10 10
2 ...P..PP 10 10 10 10 10 10 10 10
3 rP.....Q 10 10 10 10 10 10 10 10
4 .p.P.... 10 10 10 10 10 10 10 10
5 ...p..p. 10 10 10 10 10 10 10 10
6 ...bpp.p 10 10 10 10 10 10 10 10
7 ......k. 10 10 10 10 10 10 10 10
abcdefgh
move score depth nodes time flags capture color
White computer Black Human 1 eps 0 # To move White correct e1e8
Castled White false Black false # ep
TimeControl 0 Operator Time 0
White Clock 6000 Moves 1
Black Clock 6000 Moves 1
0 RB.....K 10 10 10 10 10 10 10 10
1 .B.n..P. 10 10 10 10 10 10 10 10
2 P....N.P 10 10 10 10 10 10 10 10
3 NP...... 10 10 10 10 10 10 10 10
4 ........ 10 10 10 10 10 10 10 10
5 p.pq..pQ 10 10 10 10 10 10 10 10
6 bp.b.p.p 10 10 10 10 10 10 10 10
7 ....r.k. 10 10 10 10 10 10 10 10
abcdefgh
move score depth nodes time flags capture color
Kong Sian
Technical Details
Message-ID:
<2jkrkl$cjv@nuscc.nus.sg>Path:
arc1-ca.pugleaf.net!gmd.de!xlink.net!sol.ctr.columbia.edu!destroyer!gumby!yale!yale.edu!newsserver.jvnc.net!raffles.technet.sg!nuscc.nus.sg!nsrccksShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d71d,b543eb59cc9c432d,start X-Google-Attributes: gid10d71d,public X-Google-ArrivalTime: 1994-02-13 01:24:37 PST Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!sol.ctr.columbia.edu!destroyer!gumby!yale!yale.edu!newsserver.jvnc.net!raffles.technet.sg!nuscc.nus.sg!nsrccks From: nsrccks@leonis.nus.sg (Chua Kong Sian) Newsgroups: gnu.chess Subject: Fix for repetition detection Date: 13 Feb 1994 09:24:37 GMT Organization: National University of Singapore Lines: 162 Message-ID: <2jkrkl$cjv@nuscc.nus.sg> NNTP-Posting-Host: leonis.nus.sg X-Newsreader: TIN [version 1.2 PL0]