A few positions to test movegen

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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 »

xmas79 wrote:I let mine running while out:

Code: Select all

Time elapsed: 2565.17000 seconds
Total leaf nodes: 614975507497
Yours is much faster, but mine agrees:

Code: Select all

FEN string = 8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3
Depth = 9
Leaf nodes = 614975507497
Time taken = 14221919 ms
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 »

zullil wrote: It's already in this thread, along with other positions used by John:

http://talkchess.com/forum/viewtopic.ph ... 59&t=47318
I know, that's where I originally got it. But since it catches a problem that the original set doesn't I thought it might be a useful addition to the original list of test positions. No problem if it's already there.

Actually, come to think of it, not being able to update the original post with new positions makes tracking updates to the list a bit cumbersome. Is the list on the wiki already?
User avatar
Ajedrecista
Posts: 1968
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: A few positions to test movegen.

Post by Ajedrecista »

Hello again:

If someone wants to crack the limits of his/her move generator, here is perft(10) of the position:

Code: Select all

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

  1   c4*d3e  2252209105011
  2  ke5-d5   2629527467305
  3  ke5*d4   2486035610243
  4  ke5-d6   2936067586692
  5  ke5-e6   2862406173676

Total:       13166245942927

13,166,245,942,927 (move pathes after 10 half moves).

Time: 4996.239 s (1:23:16.239).
I used JetChess 1.0.0.0 (single core, 32-bit) in an Intel Pentium D930 (3 GHz) with 1 GB of hash. One thing is sure: I will not run perft(11) or higher.

Regards from Spain.

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

Re: A few positions to test movegen.

Post by xmas79 »

zullil wrote:Yours is much faster, but mine agrees:
By a far amount considering I was using a Raspberry Pi...

Serious mode ON:
is speed of perft really that important? I don't think so, even if I tried to write it performance-wise. And how are we comparing speeds? We need to run the software on the same hardware, and even if I have a core i7 mobile @2.4GHz I don't have idea on what hardware you ran your perft...

And also consider that one year ago (when I [re]wrote my movegen/make/unmake) I really wanted it to be bug free. So instead of optimizing more and more the code to obtain raw perft speeds (eg full legal movegen), with a real chess engine in mind I preferred the SMP approach on the perft. That gave me around a 5x (from my memories) speed boost at once (I have a 8 core, 4 threads+HT), allowing me to test it faster. Also consider "this" perft version doesn't do any incremental updates in make/unmake.

In total I have three perft functions:
(1) Basic perft with gen/make/unmake (this one)
(2) Perft with full make/unmake (so hash update, PST etc...) which runs at about half speed of (1)
(3) Perft with staged move generator inside (that is hash update in make/unmake, plus the generation of moves goes through the state machine used inside search) which runs at about half speed of (2)

For each I have the corresponding SMP implementation.

Everything together allowed me to test gen/make/unmake with different degrees of precision (and speed...)
User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 10:05 pm
Location: Italy
Full name: Stefano Gemma

Re: A few positions to test movegen

Post by stegemma »

A simple position to test for castling, that's making me crazy with Satana:

[d] r3k2r/8/8/8/8/8/8/R3K2R w KQkq

perft 1: 26
perft 2: 568
perft 3: 13744
perft 4: 314346
perft 5: 7594526
perft 6: 179862938

Another simple position, for en-passant and promotion:

[d] k7/pppppppp/8/8/PPPPPPPP/8/8/K7 w

perft 1: 11
perft 2: 179
perft 3: 2188
perft 4: 33747
perft 5: 436769
perft 6: 6431450
perft 7: 85916196
perft 8: 1213722909

[d] k7/8/8/pppppppp/8/8/PPPPPPPP/K7 w

perft 1: 17
perft 2: 193
perft 3: 3073
perft 4: 37870
perft 5: 573638
perft 6: 7421393
perft 7: 107728058
perft 8: 1431021194
User avatar
Ajedrecista
Posts: 1968
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: A few positions to test movegen.

Post by Ajedrecista »

Hello Stefano:

Results confirmed by the perft counter JetChess 1.0.0.0 and extended two plies for each position:

Code: Select all

r3k2r/8/8/8/8/8/8/R3K2R w KQkq

perft(1) =              26
perft(2) =             568
perft(3) =          13,744
perft(4) =         314,346
perft(5) =       7,594,526
perft(6) =     179,862,938
perft(7) =   4,408,318,687
perft(8) = 106,978,816,283

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

k7/pppppppp/8/8/PPPPPPPP/8/8/K7 w - -

 perft(1) =              11
 perft(2) =             179
 perft(3) =           2,188
 perft(4) =          33,747
 perft(5) =         436,769
 perft(6) =       6,431,450
 perft(7) =      85,916,196
 perft(8) =   1,213,722,909
 perft(9) =  16,470,987,008
perft(10) = 224,121,854,480

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

k7/8/8/pppppppp/8/8/PPPPPPPP/K7 w - -

 perft(1) =              17
 perft(2) =             193
 perft(3) =           3,073
 perft(4) =          37,870
 perft(5) =         573,638
 perft(6) =       7,421,393
 perft(7) =     107,728,058
 perft(8) =   1,431,021,194
 perft(9) =  19,988,766,106
perft(10) = 268,779,366,342
Regards from Spain.

Ajedrecista.
User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 10:05 pm
Location: Italy
Full name: Stefano Gemma

Re: A few positions to test movegen.

Post by stegemma »

Ajedrecista wrote:Hello Stefano:

Results confirmed by the perft counter JetChess 1.0.0.0 and extended two plies for each position:[...]
Ajedrecista.
Thanks, they would be usefull. Finally iv'e found the bug in my move generator:

Code: Select all

----k--r
--------
--------
--------
--------
--------
--------
r-R--RK-
 ( ) white
e1g1
----k--r
--------
--------
--------
--------
--------
--------
r-R--RK-
 ( ) white
node-1: boEnPassantPawn=0
* updating Rc1 moves
updated Rc1: c1a1 c1e1 c1d1 c1b1 c1c2 c1c3 c1c4 c1c5 c1c6 c1c7 c1c8
* updating Kg1 moves
updated Kg1: g1h1 g1h2 g1g2 g1f2
* updating Rf1 moves
updated Rf1: f1e1 f1d1 f1f2 f1f3 f1f4 f1f5 f1f6 f1f7 f1f8
* updating rh8 moves
updated rh8: h8h1 h8h2 h8h3 h8h4 h8h5 h8h6 h8h7 h8g8 h8f8
..e1g1
----k--r
--------
--------
--------
--------
--------
--------
r-R--RK-
 (#) black
 0x24242424242427FF boWhiteChecks
00100100
00100100
00100100
00100100
00100100
00100100
00100111
11111111
 0x9E9D818181818161 boBlackChecks
10011110
10011101
10000001
10000001
10000001
10000001
10000001
01100001
[...]
----k--r
--------
--------
--------
--------
--------
--------
r-R--RK-
 ( ) white
_undoing_#     white K:e1-g1 val=0 alfaval=0
undone Ke1: e1f1 e1d1 e1f2 e1e2 e1d2 e1g1

************ HERE'S THE BUG!!! ***************
undone Rh1: f1f5 f1f6 f1f7 f1f8 h8h1 h8h2 h8h3 h8h4 h8h5 h8h6 h8h7

********************************************
undone Rc1: c1a1 c1d1 c1b1 c1c2 c1c3 c1c4 c1c5 c1c6 c1c7 c1c8
undone rh8: h8h1 h8h2 h8h3 h8h4 h8h5 h8h6 h8h7 h8g8 h8f8
e1g1 undone
----k--r
--------
--------
--------
--------
--------
--------
r-R-K--R
 ( ) white
_undone_#     white K:e1-g1 val=0 alfaval=0
#     white R:f1-f5 val=0 alfaval=0
#> Ra1-c1 ra8-a1 Rf1-f5
----k--r
--------
--------
-----R--
--------
--------
--------
r-R-KR-R
 ( ) white
f1f5
----k--r
--------
--------
-----R--
--------
--------
--------
r-R-KR-R
 ( ) white
node-1: boEnPassantPawn=0
* updating Ke1 moves
updated Ke1: e1d1 e1f2 e1e2 e1d2
* updating Rf5 moves
updated Rf5: f5f2 f5f3 f5f4 f5h5 f5g5 f5e5 f5d5 f5c5 f5b5 f5a5 f5f6 f5f7 f5f8
----k--r
--------
--------
-----R--
--------
--------
--------
r-R-KR-R
 ( ) white
 0x01000004000000A5 boRooks
00000001
00000000
00000000
00000100
00000000
00000000
00000000
10100101
 0x01000004000000A0 boRooksT
00000001
00000000
00000000
00000100
00000000
00000000
00000000
10100000
#> Ra1-c1 ra8-a1 Rf1-f5
### BAD MAKE MOVE ### nexecutes 13492
After the castling has been undone, the rook-moves should be restored to those in position h1 but it seems that they were merged and still the rook can play Rf1-f5... from h1!!! Satana started as a genetic engine so it seems that it remembered its origin and has done a genetic merging of moves ;)