perft test
Moderator: Ras
-
mvanthoor
- Posts: 1784
- Joined: Wed Jul 03, 2019 4:42 pm
- Location: Netherlands
- Full name: Marcel Vanthoor
Re: perft test
Another bug you can have due to an oversight (this happened to me) is forgetting to remove the casting rights on capturing a rook (piece) on A8, H8, A1 or H1. If white has not castled short and the rook on H1 is captured, make sure to remove the short castling rights. It's easiest to just remove the castling rights if _any_ piece moves from or to one of the corners, in youru make_move function. Castling itself is done by moving the king two squares, which is the trigger for moving the correct rook if there are castling rights.
-
R. Tomasi
- Posts: 307
- Joined: Wed Sep 01, 2021 4:08 pm
- Location: Germany
- Full name: Roland Tomasi
Re: perft test
That is a nice tip ,thank you! I will try that out in Pygmalion. I'm quite confident that my movegen is bug-free, but doing it the way you suggest might save me some branches.mvanthoor wrote: ↑Sat Sep 25, 2021 9:09 am Another bug you can have due to an oversight (this happened to me) is forgetting to remove the casting rights on capturing a rook (piece) on A8, H8, A1 or H1. If white has not castled short and the rook on H1 is captured, make sure to remove the short castling rights. It's easiest to just remove the castling rights if _any_ piece moves from or to one of the corners, in youru make_move function. Castling itself is done by moving the king two squares, which is the trigger for moving the correct rook if there are castling rights.
-
gflohr
- Posts: 57
- Joined: Fri Jul 23, 2021 5:24 pm
- Location: Elin Pelin
- Full name: Guido Flohr
Re: perft test
I have a table-based test for the perft function: https://github.com/gflohr/Chess-Plisco/ ... -by-undo.t
It contains among others the positions from chessprograming.org as well as those given by @JVMerlino (sorry for misspelling your name in the code, will be fixed first thing in the evening) earlier in this thread. Especially the latter helped me to spot a lot of subtle bugs in the move generator. I remember one case, for example, where a discovered check was given because a pawn captured en-passant was removed from the board, something like this:
[fen]8/8/8/k1pP3R/8/8/8/n4K2 w - c6 0 1[/fen]
After exb+, make sure that you do not generate knight moves.
I have another TBT that checks the legal moves from a certain position. The larger part of the positions are actually positions identified as causing bugs during the perft tests. The main advantage is that these tests run a lot faster because you just have to generate the moves for this single position.
I have another test which takes a large pgn with lots of games and plays them all from beginning to end. That gives good coverage on the SAN parser, the move generator, and the doMove/undoMove functions. For every position I also calculate the FEN representation and the signature, once from scratch by creating a new board object from the FEN and check whether its signature and FEN and the ones updated on-the-fly by the doMove/undoMove functions match. As a side-effect, that also gives me a nice check whether I have type-1 hash collisions.
It contains among others the positions from chessprograming.org as well as those given by @JVMerlino (sorry for misspelling your name in the code, will be fixed first thing in the evening) earlier in this thread. Especially the latter helped me to spot a lot of subtle bugs in the move generator. I remember one case, for example, where a discovered check was given because a pawn captured en-passant was removed from the board, something like this:
[fen]8/8/8/k1pP3R/8/8/8/n4K2 w - c6 0 1[/fen]
After exb+, make sure that you do not generate knight moves.
I have another TBT that checks the legal moves from a certain position. The larger part of the positions are actually positions identified as causing bugs during the perft tests. The main advantage is that these tests run a lot faster because you just have to generate the moves for this single position.
I have another test which takes a large pgn with lots of games and plays them all from beginning to end. That gives good coverage on the SAN parser, the move generator, and the doMove/undoMove functions. For every position I also calculate the FEN representation and the signature, once from scratch by creating a new board object from the FEN and check whether its signature and FEN and the ones updated on-the-fly by the doMove/undoMove functions match. As a side-effect, that also gives me a nice check whether I have type-1 hash collisions.
-
JVMerlino
- Posts: 1404
- Joined: Wed Mar 08, 2006 10:15 pm
- Location: San Francisco, California
Re: perft test
Credit to me is not necessary, and possibly even wrong, as I got all of those positions from other folks (who I can no longer remember, I'm afraid).gflohr wrote: ↑Tue Sep 28, 2021 2:24 pm I have a table-based test for the perft function: https://github.com/gflohr/Chess-Plisco/ ... -by-undo.t
It contains among others the positions from chessprograming.org as well as those given by @JVMerlino (sorry for misspelling your name in the code, will be fixed first thing in the evening) earlier in this thread.
-
dangi12012
- Posts: 1062
- Joined: Tue Apr 28, 2020 10:03 pm
- Full name: Daniel Infuehr
Re: perft test
And thats exactly what you dont do - to not waste time.pedrojdm2021 wrote: ↑Sat Sep 25, 2021 8:46 am and it will print me the data for the sub-tree of that a2a3, and then you have to repeat the process like you did in the root node, continue until you reach a depth of 1.
and you will end up in the position that is generating the issue.
You should use Juddperft test-external which does that recursion automatically for you. It will find wrong positions very quickly and tell you exactly whats wrong. - https://github.com/jniemann66/juddperft ... 64/Release
Greetings!
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
Daniel Inführ - Software Developer
-
ydebilloez
- Posts: 186
- Joined: Tue Jun 27, 2017 11:01 pm
- Location: Lubumbashi
- Full name: Yves De Billoëz
Re: perft test
6000+ perft test positions here: https://sourceforge.net/p/belofte/gitre ... e-full.epd
Yves De Billoëz @ macchess belofte chess
Once owner of a Mephisto I, II, challenger, ... chess computer.
Once owner of a Mephisto I, II, challenger, ... chess computer.