mvanthoor wrote: ↑Thu Jun 03, 2021 9:57 am
algerbrex wrote: ↑Thu Jun 03, 2021 4:14 am
Well, see, here's where I'm confused. The position is showed in my question is the start position I use. And I went to a depth of 2. So at a depth of two from the position is showed, d4xe5 is a move for white, a
capture move, so should it not be included along with the other captures move at a depth of 1?
If this position is the starting position for perft, then according to the FEN-string, white has the move. d4xe5 is a move on depth 1. It should thus be included in the results.
Use an engine with a known good perft, or something like QPert (by HG Muller) to verify.
My engine says:
Benchmarking perft 1-1:
8 r n b q k b n r
7 i i i i . i i i
6 . . . . . . . .
5 . . . . i . . .
4 . . . I . . . .
3 . . . . . . . .
2 I I I . I I I I
1 R N B Q K B N R
A B C D E F G H
Zobrist key: bc9b7354e69febc8
Active Color: White
Castling: KQkq
En Passant: -
Half-move clock: 0
Full-move number: 1
Perft 1: 29 (0 ms, inf leaves/sec, hash full: 0%)
Total time spent: 0 ms
Execution speed: inf leaves/second
29 moves on depth 1 for white:
16 pawn moves (including d4xe5)
5 knight moves
2 queen moves
5 bishop moves
1 king move
===
29 moves
Ok, thank you for your help so far. I think I'm starting to see where I'm going wrong. I think I have the wrong idea of what perft is suppose to look like. I based my perft function off of this example code from the chess programming wiki:
typedef unsigned long long u64;
Code: Select all
u64 Perft(int depth)
{
MOVE move_list[256];
int n_moves, i;
u64 nodes = 0;
if (depth == 0)
return 1ULL;
n_moves = GenerateLegalMoves(move_list);
for (i = 0; i < n_moves; i++) {
MakeMove(move_list[i]);
nodes += Perft(depth - 1);
UndoMove(move_list[i]);
}
return nodes;
}
And what I did is just insert a chunk of code to count if a move is an attack move. If so, I add it to the total count. So my engine gives the following output, starting at depth=2 and going down to depth=1:
Move [From: e2 To: e4 MoveType: Quiet]: (nodes=30, captures=1, checks=1, checkmates=0)
Move [From: b2 To: b4 MoveType: Quiet]: (nodes=30, captures=2, checks=1, checkmates=0)
Move [From: a2 To: a4 MoveType: Quiet]: (nodes=31, captures=1, checks=1, checkmates=0)
Move [From: g1 To: f3 MoveType: Quiet]: (nodes=31, captures=1, checks=1, checkmates=0)
Move [From: c1 To: d2 MoveType: Quiet]: (nodes=31, captures=1, checks=0, checkmates=0)
Move [From: d1 To: d2 MoveType: Quiet]: (nodes=31, captures=1, checks=0, checkmates=0)
Move [From: g2 To: g3 MoveType: Quiet]: (nodes=31, captures=1, checks=1, checkmates=0)
Move [From: c2 To: c3 MoveType: Quiet]: (nodes=31, captures=1, checks=0, checkmates=0)
Move [From: h2 To: h3 MoveType: Quiet]: (nodes=31, captures=1, checks=1, checkmates=0)
Move [From: h2 To: h4 MoveType: Quiet]: (nodes=31, captures=2, checks=1, checkmates=0)
Move [From: b2 To: b3 MoveType: Quiet]: (nodes=31, captures=1, checks=1, checkmates=0)
Move [From: c1 To: f4 MoveType: Quiet]: (nodes=32, captures=2, checks=1, checkmates=0)
Move [From: e1 To: d2 MoveType: Quiet]: (nodes=31, captures=1, checks=2, checkmates=0)
Move [From: a2 To: a3 MoveType: Quiet]: (nodes=31, captures=2, checks=1, checkmates=0)
Move [From: c1 To: h6 MoveType: Quiet]: (nodes=30, captures=3, checks=1, checkmates=0)
Move [From: c1 To: e3 MoveType: Quiet]: (nodes=31, captures=1, checks=1, checkmates=0)
Move [From: d4 To: d5 MoveType: Quiet]: (nodes=29, captures=0, checks=1, checkmates=0)
Move [From: f2 To: f3 MoveType: Quiet]: (nodes=31, captures=1, checks=2, checkmates=0)
Move [From: e2 To: e3 MoveType: Quiet]: (nodes=31, captures=1, checks=1, checkmates=0)
Move [From: b1 To: c3 MoveType: Quiet]: (nodes=31, captures=1, checks=0, checkmates=0)
Move [From: c2 To: c4 MoveType: Quiet]: (nodes=31, captures=1, checks=1, checkmates=0)
Move [From: g1 To: h3 MoveType: Quiet]: (nodes=31, captures=1, checks=1, checkmates=0)
Move [From: c1 To: g5 MoveType: Quiet]: (nodes=28, captures=2, checks=1, checkmates=0)
Move [From: d1 To: d3 MoveType: Quiet]: (nodes=31, captures=1, checks=1, checkmates=0)
Move [From: d4 To: e5 MoveType: Attack]: (nodes=29, captures=0, checks=1, checkmates=0)
Move [From: g2 To: g4 MoveType: Quiet]: (nodes=31, captures=1, checks=1, checkmates=0)
Move [From: f2 To: f4 MoveType: Quiet]: (nodes=32, captures=2, checks=2, checkmates=0)
Move [From: b1 To: a3 MoveType: Quiet]: (nodes=31, captures=2, checks=1, checkmates=0)
Move [From: b1 To: d2 MoveType: Quiet]: (nodes=31, captures=1, checks=0, checkmates=0)
------------------------------
Nodes: 891
Captures: 37
Checks: 27
Checkmates: 0
But your engine seems to be starting at a depth of 1, and counting upward towards a maximum depth. Why is that? And if my engine starts at depth=2, includes d4xe5, and then counts every capture at depth=1, should it not be 37?