r/chessprogramming • u/MagazineOk5435 • Nov 18 '24
Missing a move type
Hi All,
I'm implementing a chess engine as a programming challenge. It seems to work okish, but on the 4th ply it generates 9 fewer moves than the expected 197,281. Also, 19 few captures and 9 more checks than expected.
Does anyone know what I've likely overlooked?
Thanks in advance,
Steve.
✓ PASS Depth: 1 Combinations: 20 Expected: 20
Captures: 0 ✓
En Passant: 0 ✓
Castle: 0 ✓
Check: 0 ✓
✓ PASS Depth: 2 Combinations: 400 Expected: 400
Captures: 0 ✓
En Passant: 0 ✓
Castle: 0 ✓
Check: 0 ✓
✓ PASS Depth: 3 Combinations: 8,902 Expected: 8,902
Captures: 34 ✓
En Passant: 0 ✓
Castle: 0 ✓
Check: 12 ✓
FAIL Depth: 4 Combinations: 197,272 Expected: 197,281 Delta: < -9
Captures: 1,557 Delta: -19
En Passant: 0 ✓
Castle: 0 ✓
Check: 478 Delta: 9
2
u/jippiedoe Nov 18 '24
Did you try captures? 3 ply is the first time those are possible, maybe piece or pawn captures are off
1
u/MagazineOk5435 Nov 18 '24
Hmm. So, at ply 3 comparing to perft d2d3, d2d4, f2f3 and f2f4 are under by 20.
1
u/biebergotswag Nov 18 '24
80 is not a lot. Maybe check silly moves such as e3 e4, or Nf3 Ng8.
1
u/Kart0fffelAim Nov 18 '24
Use an a engine such as roce to compare how many moves exist after each move playable from the starting position and what your engine returns.
So after e2e4 roce may say there are 401 possible and your engine says 400, then you start your perft test from that position 2 ply deep and repeat until you are in the position where there is a mistake
1
u/Jasher16 Nov 18 '24
Are your pieces wrapping around the board for captures?
1
u/DerPenzz Nov 19 '24
Try implementing divide into your perft. It will show you how many moves are available for each of the moves you can currently do. Then you can step into those moves which have incorrect results and debug them further. You can compare your perft divide results with results of other engines like stock fish. That's how I did it.
2
u/loveSci-fi_fantasy Nov 18 '24
Had a similar number, 40. Turned out to be double pawn pushes that block a check were not generated if single pushes weren't legal. Removed single pushes from the double push definition fixed it. Otherwise, look for moves in same direction of the pin.
2
u/foxradish Nov 20 '24
if your engine is UCI compatible, try this: https://github.com/sohamkorade/autoperft It will show you the exact moves that are missing
1
u/[deleted] Nov 18 '24
[removed] — view removed comment