repetition draw bug

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: repetition draw bug

Post by lucasart »

Desperado wrote:But before i leave, what happens if you simply disable your trans-code ?
I think you're right. For a start rep should start at 1, not zero... As for i += 2 i/o 4, I'm not sure. 2 is safer anyway. I'm running a test match now. We'll see :)
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: repetition draw bug

Post by lucasart »

mar wrote: Perhaps you should look at board_is_draw instead of TT. I would drop ++rep == 3 and change i += 4 to i += 2
Thanks! I managed tio fix the problem thanks to your suggestions. My new version, if you're curious to see it, is available on WBEC.
mar
Posts: 2554
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: repetition draw bug

Post by mar »

lucasart wrote:
mar wrote: Perhaps you should look at board_is_draw instead of TT. I would drop ++rep == 3 and change i += 4 to i += 2
Thanks! I managed tio fix the problem thanks to your suggestions. My new version, if you're curious to see it, is available on WBEC.
I'm glad I could help. Will take a look, thanks.
micron
Posts: 155
Joined: Mon Feb 15, 2010 9:33 am
Location: New Zealand

Re: An easy test for repetition draw detection

Post by micron »

sje wrote:An easy test for repetition draw detection:
1) In your chess program, add a routine that will play a game with each move selected at random. This routine also reports back the reason (one of five possible) that the game ended.
2) Call the above routine a million times and summarize the results.
3) If the number of games that ended by repetition is about 2.6% of the total, then the repetition detection code is probably working.
Good test. I tried it and found a bug in my function IsTripleRepetition(), such that only 1.2% of games ended as repetition draws. A simple off-by-one bug. Hypnotised by the word "triple", I was looking for 3 matches of the current position to historical ones, instead of 2.

Before passing round the cigars and celebrating a huge ELO increase from the bug- fix, I remembered that IsTripleRepetition() isn't actually used in the search. A faster function IsRepetition() suffices, and there was no bug in that. IsTripleRepetition() gets called only in console play. Still, it's good to have found and fixed a bug. Thanks.

Robert P.
User avatar
Desperado
Posts: 879
Joined: Mon Dec 15, 2008 11:45 am

Re: An easy test for repetition draw detection

Post by Desperado »

micron wrote:
...Before passing round the cigars and celebrating a huge ELO increase...
:lol:
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: An easy test for repetition draw detection

Post by lucasart »

micron wrote:
sje wrote:An easy test for repetition draw detection:
1) In your chess program, add a routine that will play a game with each move selected at random. This routine also reports back the reason (one of five possible) that the game ended.
2) Call the above routine a million times and summarize the results.
3) If the number of games that ended by repetition is about 2.6% of the total, then the repetition detection code is probably working.
Good test. I tried it and found a bug in my function IsTripleRepetition(), such that only 1.2% of games ended as repetition draws. A simple off-by-one bug. Hypnotised by the word "triple", I was looking for 3 matches of the current position to historical ones, instead of 2.

Before passing round the cigars and celebrating a huge ELO increase from the bug- fix, I remembered that IsTripleRepetition() isn't actually used in the search. A faster function IsRepetition() suffices, and there was no bug in that. IsTripleRepetition() gets called only in console play. Still, it's good to have found and fixed a bug. Thanks.

Robert P.
I've tested, and I can assure you that it's time for the cigars :wink:
as you exaplain quite rightly, the point is that the function called in the search should not search triple repetition but simply repetition...
User avatar
stevemulligan
Posts: 117
Joined: Wed Jul 20, 2011 2:54 pm
Location: Ottawa, Canada

Re: An easy test for repetition draw detection

Post by stevemulligan »

sje wrote: Count: 1,000,000 Elapsed: 204.051 (4900.75 Hz / 0.000204051 s)
Does it have to be a million games to get good results? Could I get away with 100k games?

My engine is so slow it would take me 1.48 million seconds or about 17 days to run, compared to your 204 seconds?? (I'm in c#, and a 1.8Ghz single core, but it really shouldn't be creating that much of a difference)
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: An easy test for repetition draw detection

Post by sje »

stevemulligan wrote:
sje wrote: Count: 1,000,000 Elapsed: 204.051 (4900.75 Hz / 0.000204051 s)
Does it have to be a million games to get good results? Could I get away with 100k games?

My engine is so slow it would take me 1.48 million seconds or about 17 days to run, compared to your 204 seconds?? (I'm in c#, and a 1.8Ghz single core, but it really shouldn't be creating that much of a difference)
These games are random games and do not use any search. My posted result was from a single thread on a 2.67 GHz Xeon 5150.
micron
Posts: 155
Joined: Mon Feb 15, 2010 9:33 am
Location: New Zealand

Re: An easy test for repetition draw detection

Post by micron »

stevemulligan wrote: Does it have to be a million games to get good results? Could I get away with 100k games?
You don't need a million. I just tried it, and 100k would be easily enough to show major discrepancy from the expected 2.5% repetition draws.
User avatar
stevemulligan
Posts: 117
Joined: Wed Jul 20, 2011 2:54 pm
Location: Ottawa, Canada

Re: An easy test for repetition draw detection

Post by stevemulligan »

sje wrote: These games are random games and do not use any search.
Sadly, mine were too. I'll try with 100k, that should only take me a day complete :{

My move generation is terrible. I get slow perft results too. I guess I should try and speed it up. I spend all most of my time checking for check.

Image