Perft and theoretic draws (FIDE)

Discussion of chess software programming and technical issues.

Moderator: Ras

ydebilloez
Posts: 179
Joined: Tue Jun 27, 2017 11:01 pm
Location: Lubumbashi
Full name: Yves De Billoëz

Perft and theoretic draws (FIDE)

Post by ydebilloez »

Hi all,

I fixed some issue in my chess program and came across an issue in perft test-suites.

As per FIDE rules, following position is a theoretic draw. (FEN + EPD format)
8/8/8/8/8/8/8/KNk5 b - - 0 1 ;D0 1 ;D1 1 ;D2 1

As per perft definition, we find the number of moves being equal to 1 or more. So even if position is showing draw, we still return 1 as per perft definition on depth 0. So above line assumes in a perft test that perft 1, perft 2 and perft 3 all return 1.

In FIDE rules, as black cannot be mated with a KNK position, there is no move as the game ends with a draw before the first move is played. In Xboard (CECP) protocol, the first move is played (e.g. Kc2) and a draw is reported. In UCI, nothing is reported and play continues and it is up to UI to declare draw.

Perftsuites however disregard theoretic draws and assume that black has 2 moves.

I can assume that 3 fold repetition or 50 moves can be omitted in perftsuites as draw claim comes from player. But insufficient material is somewhat enforced.

My questions:
Shouldn't perft testsuites be corrected and assumes games terminates once a theoretic draw is achieved?
Secondary question, has someone perftsuites with these corrections in them?

Reference: 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.
User avatar
Brunetti
Posts: 424
Joined: Tue Dec 08, 2009 1:37 pm
Location: Milan, Italy
Full name: Alex Brunetti

Re: Perft and theoretic draws (FIDE)

Post by Brunetti »

ydebilloez wrote: Wed Feb 19, 2025 12:58 pm Shouldn't perft testsuites be corrected and assumes games terminates once a theoretic draw is achieved?
Secondary question, has someone perftsuites with these corrections in them?
Hello,
only a small portion of immediate draw positions can be easily identified by software, so even considering the simplest material combinations, such as KNK or KBK, millions of positions would still be excluded.

Here, for example, I think any software in the world would give perft 2 = 28, while the correct value should be 25.

[d]nk5b/p1p5/PpPp4/1P1Pp3/5p1p/4PPpP/6P1/5B1K w - - 0 1

What would be the purpose of reading 25? The function of perft should be to test the move generator, so if everyone agrees on the (incorrect) value of 28, I think that's fine.

Alex
User avatar
Ras
Posts: 2696
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Perft and theoretic draws (FIDE)

Post by Ras »

Moderation: Moved topic to this forum, upon Yves' request.
Rasmus Althoff
https://www.ct800.net
ydebilloez
Posts: 179
Joined: Tue Jun 27, 2017 11:01 pm
Location: Lubumbashi
Full name: Yves De Billoëz

Re: Perft and theoretic draws (FIDE)

Post by ydebilloez »

Brunetti wrote: Wed Feb 19, 2025 6:53 pm
ydebilloez wrote: Wed Feb 19, 2025 12:58 pm Shouldn't perft testsuites be corrected and assumes games terminates once a theoretic draw is achieved?
Secondary question, has someone perftsuites with these corrections in them?
Hello,
only a small portion of immediate draw positions can be easily identified by software, so even considering the simplest material combinations, such as KNK or KBK, millions of positions would still be excluded.

Here, for example, I think any software in the world would give perft 2 = 28, while the correct value should be 25.

What would be the purpose of reading 25? The function of perft should be to test the move generator, so if everyone agrees on the (incorrect) value of 28, I think that's fine.

Alex
I mean that in this position, possible moves are 0 as it is a draw. Yet most perft suites do not take this into account and assume that 2 is the correct answer. I am looking for perft suites or programs that handle this correctly. The move generator shouldn't be generating any moves here.

[d]8/8/8/8/8/8/8/KNk5 b - - 0 1
Yves De Billoëz @ macchess belofte chess
Once owner of a Mephisto I, II, challenger, ... chess computer.
User avatar
Brunetti
Posts: 424
Joined: Tue Dec 08, 2009 1:37 pm
Location: Milan, Italy
Full name: Alex Brunetti

Re: Perft and theoretic draws (FIDE)

Post by Brunetti »

ydebilloez wrote: Sat Feb 22, 2025 9:35 pm I mean that in this position, possible moves are 0 as it is a draw. Yet most perft suites do not take this into account and assume that 2 is the correct answer.
Yes, that's exactly what I understood, and in this position too, the possible moves are exactly 0:

[d]nk5b/p1p5/PpPp4/1P1Pp3/4Pp1p/5PpP/6P1/5B1K w - - 0 1

As I wrote, it's practically impossible for a program to determine that a position is dead, so only a few could be classified, like KNk. But why that one and, for example, not those with 5 white bishops and 3 black bishops, all on light squares?
ydebilloez wrote: Sat Feb 22, 2025 9:35 pm I am looking for perft suites or programs that handle this correctly. The move generator shouldn't be generating any moves here.
Since it's impossible to identify all dead positions, you won't find any move generator implementation that takes them into account. And if it did (but only for the very few where it's possible), it would differ from all other move generators, making its use pointless. At the same time, a perft suite that considers dead positions would be completely useless for the same reason.

Alex
User avatar
phhnguyen
Posts: 1524
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: Perft and theoretic draws (FIDE)

Post by phhnguyen »

ydebilloez wrote: Wed Feb 19, 2025 12:58 pm Hi all,

I fixed some issue in my chess program and came across an issue in perft test-suites.

As per FIDE rules, following position is a theoretic draw. (FEN + EPD format)
8/8/8/8/8/8/8/KNk5 b - - 0 1 ;D0 1 ;D1 1 ;D2 1

As per perft definition, we find the number of moves being equal to 1 or more. So even if position is showing draw, we still return 1 as per perft definition on depth 0. So above line assumes in a perft test that perft 1, perft 2 and perft 3 all return 1.

In FIDE rules, as black cannot be mated with a KNK position, there is no move as the game ends with a draw before the first move is played. In Xboard (CECP) protocol, the first move is played (e.g. Kc2) and a draw is reported. In UCI, nothing is reported and play continues and it is up to UI to declare draw.

Perftsuites however disregard theoretic draws and assume that black has 2 moves.

I can assume that 3 fold repetition or 50 moves can be omitted in perftsuites as draw claim comes from player. But insufficient material is somewhat enforced.

My questions:
Shouldn't perft testsuites be corrected and assumes games terminates once a theoretic draw is achieved?
Secondary question, has someone perftsuites with these corrections in them?

Reference: https://sourceforge.net/p/belofte/gitre ... e-full.epd
You can do freely what you want, from modifying Perft algorithms to publishing new results. However, you should use different names, such as Perft 2, True Perft, Yves-Perft, etc...

The Perft should be used AS IT. Otherwise, people get confused and debugging delays.

Your posted issue has been known and asked multiple times. For example, here is one.
https://banksiagui.com
The most features chess GUI, based on opensource Banksia - the chess tournament manager