A bug in Stockfish move generator?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
vittyvirus
Posts: 646
Joined: Wed Jun 18, 2014 2:30 pm
Full name: Fahad Syed

A bug in Stockfish move generator?

Post by vittyvirus »

Sorry, I don't have the latest release.

Code: Select all

Stockfish 010215 64 POPCNT by Tord Romstad, Marco Costalba and Joona Kiiski
position fen 1Q5Q/8/3p1p2/2RpkpR1/2PpppP1/2QPQPB1/8/4K3 b - - 0 1
perft 5

Position: 1/1
d4c3: 76423
e5e6: 399459
f4g3: 91221

===========================
Total time (ms) : 15
Nodes searched  : 567103
Nodes/second    : 37806866
perft 6

Position: 1/1
d4c3: 4113476
e5e6: 26199317
f4g3: 5322284

===========================
Total time (ms) : 235
Nodes searched  : 35635077
Nodes/second    : 151638625
perft 7

Position: 1/1
d4c3: 32734266
e5e6: 215023250
f4g3: 42305829

===========================
Total time (ms) : 6766
Nodes searched  : [b]290063345[/b]
Nodes/second    : 42870727

Hash-table size = 1ffffff, Starts at 66d040,section = 3fffff
 - - - - - - - - - - - -
 - - - - - - - - - - - -
 - - . Q . . . . . Q - -
 - - . . . . . . . . - -
 - - . . . p . p . . - -
 - - . . R p k p R . - -
 - - . . P p p p P . - -
 - - . . Q P Q P B . - -
 - - . . . . . . . . - -
 - - . . . . K . . . - -
 - - - - - - - - - - - -
 - - - - - - - - - - - -

Quick Perft by H.G. Muller
Perft mode: Hash-table size = 512MB, bulk counting in horizon nodes

perft( 1)=            3 ( 0.000 sec)
perft( 2)=          202 ( 0.000 sec)
perft( 3)=         1130 ( 0.000 sec)
perft( 4)=        74235 ( 0.000 sec)
perft( 5)=       567103 ( 0.031 sec)
perft( 6)=     35635077 ( 0.125 sec)
perft( 7)=    290565474 ( 2.829 sec)


frcperft 1.0, (C) 2008-2011 AJ Siemelink
single threaded, no hashing, mode=FAST, extract=BUILTIN, count=BUILTIN

   +---+---+---+---+---+---+---+---+
 8 |*r*|*n*|*b*|*q*|*k*|*b*|*n*|*r*|
   +---+---+---+---+---+---+---+---+
 7 |*p*|*p*|*p*|*p*|*p*|*p*|*p*|*p*|
   +---+---+---+---+---+---+---+---+
 6 |   |   |   |   |   |   |   |   |
   +---+---+---+---+---+---+---+---+
 5 |   |   |   |   |   |   |   |   |
   +---+---+---+---+---+---+---+---+
 4 |   |   |   |   |   |   |   |   |
   +---+---+---+---+---+---+---+---+
 3 |   |   |   |   |   |   |   |   |
   +---+---+---+---+---+---+---+---+
 2 |(P)|(P)|(P)|(P)|(P)|(P)|(P)|(P)|
   +---+---+---+---+---+---+---+---+
 1 |(R)|(N)|(B)|(Q)|(K)|(B)|(N)|(R)|
   +---+---+---+---+---+---+---+---+
     a   b   c   d   e   f   g   h

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
interactive mode, type 'help'+Enter for help
% fen 1Q5Q/8/3p1p2/2RpkpR1/2PpppP1/2QPQPB1/8/4K3 b - - 0 1

   +---+---+---+---+---+---+---+---+
 8 |   |(Q)|   |   |   |   |   |(Q)|
   +---+---+---+---+---+---+---+---+
 7 |   |   |   |   |   |   |   |   |
   +---+---+---+---+---+---+---+---+
 6 |   |   |   |*p*|   |*p*|   |   |
   +---+---+---+---+---+---+---+---+
 5 |   |   |(R)|*p*|*k*|*p*|(R)|   |
   +---+---+---+---+---+---+---+---+
 4 |   |   |(P)|*p*|*p*|*p*|(P)|   |
   +---+---+---+---+---+---+---+---+
 3 |   |   |(Q)|(P)|(Q)|(P)|(B)|   |
   +---+---+---+---+---+---+---+---+
 2 |   |   |   |   |   |   |   |   |
   +---+---+---+---+---+---+---+---+
 1 |   |   |   |   |(K)|   |   |   |
   +---+---+---+---+---+---+---+---+
     a   b   c   d   e   f   g   h

1Q5Q/8/3p1p2/2RpkpR1/2PpppP1/2QPQPB1/8/4K3 b - - 0 1
% perft 7
perft 1              3       0.00s      1.$ mnps 6602.7 ticks/move
perft 2            202       0.00s      1.$ mnps   52.7 ticks/move
perft 3           1130       0.00s      1.$ mnps   96.3 ticks/move
perft 4          74235       0.00s      1.$ mnps    5.6 ticks/move
perft 5         567103       0.00s      1.$ mnps   38.0 ticks/move
perft 6       35635077       0.06s    574.8 mnps    3.9 ticks/move
perft 7      290063345       3.23s     89.7 mnps   26.6 ticks/move
%
syzygy
Posts: 5562
Joined: Tue Feb 28, 2012 11:56 pm

Re: A bug in Stockfish move generator?

Post by syzygy »

Why the title, if Stockfish is in the majority?

It is Quick Perft that gets it wrong. I don't know if this is the same bug as one that was reported not too long ago (if I remember correctly).

An old copy of Quick Perft that I have here produces the correct result without hashing. It seems to crash with hash already at 3 plies.
User avatar
Ajedrecista
Posts: 1968
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: A bug in Stockfish move generator?

Post by Ajedrecista »

Hello:

Results by JetChess 1.0.0.0:

[d]1Q5Q/8/3p1p2/2RpkpR1/2PpppP1/2QPQPB1/8/4K3 b - - 0 1

Code: Select all

perft(5)

  1   d4*c3         76423
  2   f4*g3         91221
  3  ke5-e6        399459

Total:             567103

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

perft(6)

  1   d4*c3       4113476
  2   f4*g3       5322284
  3  ke5-e6      26199317

Total:           35635077

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

perft(7)

  1   d4*c3      32734266
  2   f4*g3      42305829
  3  ke5-e6     215023250

Total:          290063345

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

perft(8)

  1   d4*c3    1723938607
  2   f4*g3    2431506974
  3  ke5-e6   13510381415

Total:        17665826996

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

perft(9)

  1   d4*c3   15069224218
  2   f4*g3   21089191126
  3  ke5-e6  109600957345

Total:       145759372689
The value of perft(7) is identical for both SF 010215, frcperft 1.0 and JetChess 1.0.0.0; only qperft differs... There was a rare bug in qperft with hash. It is strange because qperft is very reliable, but who knows?

A good idea could be play dxc3, fxg3 and Ke6 and run perft(7 - 1) = perft(6) of those three positions with different perft counters and check if the difference continues.

By the way, using a self-compiled version of qperft:

Code: Select all

[...]\qperft>qperft 7 "1Q5Q/8/3p1p2/2RpkpR1/2PpppP1/2QPQPB1/8/4K3 b - - 0 1"
 - - - - - - - - - - - -
 - - - - - - - - - - - -
 - - . Q . . . . . Q - -
 - - . . . . . . . . - -
 - - . . . p . p . . - -
 - - . . R p k p R . - -
 - - . . P p p p P . - -
 - - . . Q P Q P B . - -
 - - . . . . . . . . - -
 - - . . . . K . . . - -
 - - - - - - - - - - - -
 - - - - - - - - - - - -

Quick Perft by H.G. Muller
Perft mode: No hashing, bulk counting in horizon nodes

perft( 1)=            3 ( 0.000 sec)
perft( 2)=          202 ( 0.000 sec)
perft( 3)=         1130 ( 0.000 sec)
perft( 4)=        74235 ( 0.000 sec)
perft( 5)=       567103 ( 0.063 sec)
perft( 6)=     35635077 ( 0.422 sec)
perft( 7)=    290063345 (25.734 sec)

[...]\qperft>qperft 7 H25 "1Q5Q/8/3p1p2/2RpkpR1/2PpppP1/2QPQPB1/8/4K3 b - - 0 1"
Hash-table size = 1ffffff, Starts at 760040,section = 3fffff
 - - - - - - - - - - - -
 - - - - - - - - - - - -
 - - . Q . . . . . Q - -
 - - . . . . . . . . - -
 - - . . . p . p . . - -
 - - . . R p k p R . - -
 - - . . P p p p P . - -
 - - . . Q P Q P B . - -
 - - . . . . . . . . - -
 - - . . . . K . . . - -
 - - - - - - - - - - - -
 - - - - - - - - - - - -

Quick Perft by H.G. Muller
Perft mode: Hash-table size = 512MB, bulk counting in horizon nodes

perft( 1)=            3 ( 0.000 sec)
perft( 2)=          202 ( 0.000 sec)
perft( 3)=         1130 ( 0.000 sec)
perft( 4)=        74235 ( 0.000 sec)
perft( 5)=       567103 ( 0.046 sec)
perft( 6)=     35635077 ( 0.297 sec)
perft( 7)=    290565474 ( 7.203 sec)
I agree with Ronald: hashing gives problems to qperft in this position.

Regards from Spain.

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

Symbolic says

Post by sje »

Symbolic says:

Code: Select all

[] sf 1Q5Q/8/3p1p2/2RpkpR1/2PpppP1/2QPQPB1/8/4K3 b - - 0 1 
[] sbo tre0
[] pctran 5
E0: fxg3 91,221
E0: dxc3 76,423
E0: Ke6 399,459
Count: 567,103   Pt: 0.052   Wt: 0.013   U: 0.969601   43.2862 MHz   23.1021 ns
[] pctran 6
E0: fxg3 5,322,284
E0: dxc3 4,113,476
E0: Ke6 26,199,317
Count: 35,635,077   Pt: 0.238   Wt: 0.060   U: 0.981116   596.678 MHz   1.67595 ns
[] pctran 7
E0: Ke6 215,023,250
E0: fxg3 42,305,829
E0: dxc3 32,734,266
Count: 290,063,345   Pt: 7.545   Wt: 1.913   U: 0.985559   153.77 MHz   6.5032 ns
[] pctran 8
E0: Ke6 13,510,381,415
E0: fxg3 2,431,506,974
E0: dxc3 1,723,938,607
Count: 17,665,826,996   Pt: 30.307   Wt: 7.734   U: 0.979601   2.33158 GHz   428.894 ps
[] pctran 9
E0: Ke6 109,600,957,345
E0: fxg3 21,089,191,126
E0: dxc3 15,069,224,218
Count: 145,759,372,689   Pt: 11:12.065   Wt: 2:51.707   U: 0.978506   867.531 MHz   1.1527 ns
As always, 128 bit hash signatures are in use.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Also, perft(10)

Post by sje »

After a few more minutes, perft(10):

Code: Select all

[] pctran 10
E0: Ke6 6,611,095,289,806
E0: dxc3 772,852,868,294
E0: fxg3 1,182,389,450,426
Count: 8,566,337,608,526   Pt: 44:11.107   Wt: 11:21.042   U: 0.97318   12.9249 GHz   77.3699 ps
User avatar
Ajedrecista
Posts: 1968
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: Also, perft(10)... and almost perft(11).

Post by Ajedrecista »

Hello Steven:
sje wrote:After a few more minutes, perft(10):

Code: Select all

[] pctran 10
E0: Ke6 6,611,095,289,806
E0: dxc3 772,852,868,294
E0: fxg3 1,182,389,450,426
Count: 8,566,337,608,526   Pt: 44:11.107   Wt: 11:21.042   U: 0.97318   12.9249 GHz   77.3699 ps
Your value is confirmed by JetChess 1.0.0.0 (single core, 32-bit). Intel i5-4670K (3.4 GHz) and 1 GB of hash:

Code: Select all

1Q5Q/8/3p1p2/2RpkpR1/2PpppP1/2QPQPB1/8/4K3 b - - 0 1

  1   d4*c3    772852868294
  2   f4*g3   1182389450426
  3  ke5-e6   6611095289806

Total:        8566337608526

8,566,337,608,526 (move pathes after 10 half moves).

Time: 958.815 s (0:15:58.815).
I tried to run perft(11) of that position with the same conditions but the count did not finish. Provisional results after the stop of the run:

Code: Select all

1Q5Q/8/3p1p2/2RpkpR1/2PpppP1/2QPQPB1/8/4K3 b - - 0 1

  1   d4*c3   7156008692343
  2   f4*g3  10712521064193

Running...
This run lasted three or four hours more less and it is unfinished. I suppose that it will finish if I let it run some more hours. I will start it again tomorrow if I remember and if it does not finish then I will not try it again.

Regards from Spain.

Ajedrecista.
User avatar
Ajedrecista
Posts: 1968
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: perft(11) done.

Post by Ajedrecista »

Hi again:

The run finally finished:

Code: Select all

1Q5Q/8/3p1p2/2RpkpR1/2PpppP1/2QPQPB1/8/4K3 b - - 0 1

  1   d4*c3   7156008692343
  2   f4*g3  10712521064193
  3  ke5-e6  53536637535848

Total:       71405167292384

71,405,167,292,384 (move pathes after 11 half moves).

Time: 19961.658 s (5:32:41.658).
Regards from Spain.

Ajedrecista.