A few positions to test movegen

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: A few positions to test movegen

Post by sje »

Evert wrote:
lucasart wrote: I saw that. But I will still keep your positions. DiscoCheck doesn't care if a position can be reached in a real game or not, and it should not assume that the ep square would be empty is ep capture is illegal (I don't see how to use that info in any useful way to speed up the program).
The en-passant capture being illegal is actually not the problem in itself.

[d]8/5bk1/8/2Pp4/8/1K6/8/8 w - d6 0 1
Given that there's an en-passant capture, Black's last move must have been d7-d5, but then the white king was in check during black's turn - which is illegal.

Jazz (and Leonidas) verify if a move leaves the king in check (unless the move is an evasion, in which case they already know that it's a legal move). One of the short-cuts taken is that an en-passant capture cannot leave the king in check, unless the king is on the same rank (the well-known "pinned en-passant capture" pitfall). Making this test more general (so it would be "correct" in the above position) slows things down measurably (but still not very much). Sjaak is far too general an engine to have a legal evasion generator and so gets this position "right" anyway.

As I recall, you always do legal move generation, so it may be less of an issue there, but I would still imagine you can get a minor speedup by not doing the test for something that never happens in a real game...
Oscar knows:

Code: Select all

gail:tmp sje$ ./operft "8/5bk1/8/2Pp4/8/1K6/8/8 w - d6 0 1" 1
Bad FEN
gail:tmp sje$  
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: A few positions to test movegen

Post by jdart »

Arasan ran these with 0 errors, as I expected. I'm sure it has plenty of bugs, just not in the move generator.

Thanks for providing these tests. I have added them to my unit test module.

--Jon
Richard Allbert
Posts: 792
Joined: Wed Jul 19, 2006 9:58 am

Re: A few positions to test movegen

Post by Richard Allbert »

jdart wrote:Arasan ran these with 0 errors, as I expected. I'm sure it has plenty of bugs, just not in the move generator.

Thanks for providing these tests. I have added them to my unit test module.

--Jon
It's a nervous wait, though isn't it? :)

I've had a lot of long haul flights with work recently, and have been rewriting Lime on the plane - and began collecting as many positions as possible. Some good positions here.

I did allow the 'illegal' FEN above, though.
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: A few positions to test movegen

Post by jdart »

Re testing : my opening book generator runs through about 750,000 games, parsing and executing each move, and checking legality. So that is maybe 40-50 million positions.

Plus I sometimes run the engine with debug enabled and many asserts turned on. So that is another fairly stringent test. If ever an illegal move is executed it will probably fail one of the asserts.

That is why I didn't expect problems in the movegen area.

--Jon
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: A few positions to test movegen

Post by Evert »

I recently found a case that wasn't covered by any of the test positions listed here: resolving check by en-passant capture of the checking pawn. This is the relevant position (comments say it comes from John Merlino's test set):

[D]8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 28

perft 4: 67197
perft 6: 38633283
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: A few positions to test movegen

Post by zullil »

Evert wrote:I recently found a case that wasn't covered by any of the test positions listed here: resolving check by en-passant capture of the checking pawn. This is the relevant position (comments say it comes from John Merlino's test set):

[D]8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 28

perft 4: 67197
perft 6: 38633283
It's already in this thread, along with other positions used by John:

http://talkchess.com/forum/viewtopic.ph ... 59&t=47318
User avatar
Ajedrecista
Posts: 1966
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: A few positions to test movegen.

Post by Ajedrecista »

Hello:
Evert wrote:I recently found a case that wasn't covered by any of the test positions listed here: resolving check by en-passant capture of the checking pawn. This is the relevant position (comments say it comes from John Merlino's test set):

Code: Select all

8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 28

perft 4: 67197
perft 6: 38633283
Good to know that perft counter JetChess agrees:

Code: Select all

8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 28

-------------------------

perft(1)

Total:                  5

-------------------------

perft(2)

  1   c4*d3e           23
  2  ke5-d5            23
  3  ke5*d4            23
  4  ke5-d6            24
  5  ke5-e6            24

Total:                117

-------------------------

perft(3)

  1   c4*d3e          624
  2  ke5-d5           672
  3  ke5*d4           639
  4  ke5-d6           676
  5  ke5-e6           682

Total:               3293

-------------------------

perft(4)

  1   c4*d3e        12471
  2  ke5-d5         13428
  3  ke5*d4         13030
  4  ke5-d6         14117
  5  ke5-e6         14151

Total:              67197

-------------------------

perft(5)

  1   c4*d3e       341894
  2  ke5-d5        382530
  3  ke5*d4        360136
  4  ke5-d6        401106
  5  ke5-e6        395423

Total:            1881089

-------------------------

perft(6)

  1   c4*d3e      6879553
  2  ke5-d5       7747197
  3  ke5*d4       7438869
  4  ke5-d6       8335508
  5  ke5-e6       8232156

Total:           38633283

-------------------------

perft(7)

  1   c4*d3e    188764129
  2  ke5-d5     216135695
  3  ke5*d4     202248953
  4  ke5-d6     233877684
  5  ke5-e6     228162609

Total:         1069189070

-------------------------

perft(8)

  1   c4*d3e   3899646321
  2  ke5-d5    4505399674
  3  ke5*d4    4291215523
  4  ke5-d6    4947659966
  5  ke5-e6    4844580296

Total:        22488501780

-------------------------

perft(9)

  1   c4*d3e 106718015882
  2  ke5-d5  123552363384
  3  ke5*d4  114933529736
  4  ke5-d6  136792876768
  5  ke5-e6  132978721727

Total:       614975507497
Regards from Spain.

Ajedrecista.
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: A few positions to test movegen.

Post by zullil »

Ajedrecista wrote:Hello:
Evert wrote:I recently found a case that wasn't covered by any of the test positions listed here: resolving check by en-passant capture of the checking pawn. This is the relevant position (comments say it comes from John Merlino's test set):

Code: Select all

8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 28

perft 4: 67197
perft 6: 38633283
Good to know that perft counter JetChess agrees:

Code: Select all

8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 28

-------------------------

perft(1)

Total:                  5

-------------------------

perft(2)

  1   c4*d3e           23
  2  ke5-d5            23
  3  ke5*d4            23
  4  ke5-d6            24
  5  ke5-e6            24

Total:                117

-------------------------

perft(3)

  1   c4*d3e          624
  2  ke5-d5           672
  3  ke5*d4           639
  4  ke5-d6           676
  5  ke5-e6           682

Total:               3293

-------------------------

perft(4)

  1   c4*d3e        12471
  2  ke5-d5         13428
  3  ke5*d4         13030
  4  ke5-d6         14117
  5  ke5-e6         14151

Total:              67197

-------------------------

perft(5)

  1   c4*d3e       341894
  2  ke5-d5        382530
  3  ke5*d4        360136
  4  ke5-d6        401106
  5  ke5-e6        395423

Total:            1881089

-------------------------

perft(6)

  1   c4*d3e      6879553
  2  ke5-d5       7747197
  3  ke5*d4       7438869
  4  ke5-d6       8335508
  5  ke5-e6       8232156

Total:           38633283

-------------------------

perft(7)

  1   c4*d3e    188764129
  2  ke5-d5     216135695
  3  ke5*d4     202248953
  4  ke5-d6     233877684
  5  ke5-e6     228162609

Total:         1069189070

-------------------------

perft(8)

  1   c4*d3e   3899646321
  2  ke5-d5    4505399674
  3  ke5*d4    4291215523
  4  ke5-d6    4947659966
  5  ke5-e6    4844580296

Total:        22488501780

-------------------------

perft(9)

  1   c4*d3e 106718015882
  2  ke5-d5  123552363384
  3  ke5*d4  114933529736
  4  ke5-d6  136792876768
  5  ke5-e6  132978721727

Total:       614975507497
Regards from Spain.

Ajedrecista.
Even my move generator seems OK---though it's too slow to try perft(9).

Code: Select all

louis@LZsT5610:~/Documents/Chess/Kirby$ ./perft 
FEN string = 8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3
Depth = 4
Leaf nodes = 67197
Time taken = 3 ms
louis@LZsT5610:~/Documents/Chess/Kirby$ ./perft 
FEN string = 8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3
Depth = 5
Leaf nodes = 1881089
Time taken = 67 ms
louis@LZsT5610:~/Documents/Chess/Kirby$ ./perft 
FEN string = 8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3
Depth = 6
Leaf nodes = 38633283
Time taken = 793 ms
louis@LZsT5610:~/Documents/Chess/Kirby$ ./perft 
FEN string = 8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3
Depth = 7
Leaf nodes = 1069189070
Time taken = 24058 ms
louis@LZsT5610:~/Documents/Chess/Kirby$ ./perft 
FEN string = 8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3
Depth = 8
Leaf nodes = 22488501780
Time taken = 389329 ms
JVMerlino
Posts: 1357
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: A few positions to test movegen

Post by JVMerlino »

zullil wrote:
Evert wrote:I recently found a case that wasn't covered by any of the test positions listed here: resolving check by en-passant capture of the checking pawn. This is the relevant position (comments say it comes from John Merlino's test set):

[D]8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 28

perft 4: 67197
perft 6: 38633283
It's already in this thread, along with other positions used by John:

http://talkchess.com/forum/viewtopic.ph ... 59&t=47318
I have no idea who originally sent me this position, but it can be found here (CC Wiki gives credit to Reinhard Scharnagl for this site):

http://www.10x8.net/chess/PerfT.html

jm
xmas79
Posts: 286
Joined: Mon Jun 03, 2013 7:05 pm
Location: Italy

Re: A few positions to test movegen.

Post by xmas79 »

I let mine running while out:

Code: Select all

Time elapsed: 2565.17000 seconds
Total leaf nodes: 614975507497