sandermvdb / chess22k

Chessengine written in Java
GNU General Public License v3.0
31 stars 8 forks source link

Wrong node count for Kiwipete Perft #15

Closed osvitashev closed 2 years ago

osvitashev commented 2 years ago

Not sure if something is wrong on my end, or the library, but i am getting wrong node count for Perft:

I get Depth: 4 Perft rezult: 4078017 total nodes, whereas it is supposed to be 4085603

package nl.s22k.chess;
import nl.s22k.chess.maintests.Perft;
import nl.s22k.chess.search.ThreadData;
public class TestPerftChess22k {
   public static void main(String[] args) {
      ChessBoardInstances.init(1);
      ThreadData.initInstances(1);
      ChessBoard cb = ChessBoardInstances.get(0);
      ThreadData threadData = ThreadData.getInstance(0);
      ChessBoardUtil.setFen("r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -", cb);
      for(int i=2; i<7; ++i) {
         long startTime = System.nanoTime();
         long nodes = Perft.perft(cb, threadData, i);
         long stopTime = System.nanoTime();
         double runTime = (stopTime-startTime)/1000000000.00 ;
         System.out.println("Depth: "+i+" Perft rezult: " + nodes + " total nodes in " 
            + runTime + " seconds, or " + (nodes/runTime)/1000000.00 + " Mn/s");
      }
   }
}
AlexBrunetti commented 2 years ago

You can implement a "divide" function and find in a few seconds where's the problem.

Alex

sandermvdb commented 2 years ago

I did use Perft extensively, including the Kiwipete position, see: https://github.com/sandermvdb/chess22k/blob/master/src/main/java/nl/s22k/chess/maintests/Perft.java

The reason you are getting less moves is because under-promotions need to be enabled: if (!EngineConstants.GENERATE_BR_PROMOTIONS) { System.out.println("Generation of underpromotions is disabled!"); }

The reason these are disabled because more moves are being generated (and need to be searched) but they are almost never usefull.

osvitashev commented 2 years ago

@sandermvdb oh, makes sense! I should have spent tome time looking at your tests. Thanks for clarification!