fairy-stockfish / Fairy-Stockfish

chess variant engine supporting Xiangqi, Shogi, Janggi, Makruk, S-Chess, Crazyhouse, Bughouse, and many more
https://fairy-stockfish.github.io/
GNU General Public License v3.0
621 stars 196 forks source link

Immediate draws by repetition/moves (fivefold, 75-move rule) #387

Open thearst3rd opened 3 years ago

thearst3rd commented 3 years ago

Curious about your thoughts on this, since it doesn't actually affect engine play but would be nice for the libraries. Right now, only optional draws by n-fold repetition and n-move rule are supported - I was wondering about the possibility of adding "immediate" draws by m-fold and m-move rule (such as fivefold repetition and 75-move rule in standard chess). I feel like it should be relatively easy to add (maybe 😄), do you think it would be worth the effort?

Ex:

[example:example]
nMoveRule = 50
nMoveRuleImmediate = 75
nFoldRule = 3
nFoldRuleImmediate = 5
ianfab commented 3 years ago

Yes, it should be rather trivial to add. However, I am somewhat sceptical of the change for several reasons:

thearst3rd commented 3 years ago

All fair points!

Anyways I created the issue since it's technically a rule of chess that Fairy-Stockfish doesn't support, but I understand if it's out of scope for the project :)

gbtami commented 3 years ago

On pychess site (similar to lichess) infinite game issue is solved by the 300 move limit.

ianfab commented 3 years ago

Implementing it as a separate method of course is an option. Still, I think that it is not like any other rule of chess, considering that it is not very well established in practice (it is a quite recent change, I am not yet aware of any software supporting it, and I have never seen it applied OTB) apart from being defined by FIDE. Nevertheless, I get your point, and I am open to applying an isolated change that does not affect the engine to provide this for the libraries.

One more thing to consider though is that if introduced as a variant configuration it creates overhead for the definition of variants. Also if it would be available for all variants, things like armageddon should be considered as well. In general it sounds like more fitting to a chess-only library, unless there are similar rules for other variants that justify introducing it as a general concept.

thearst3rd commented 3 years ago

For software that supports it, I know that python-chess does:

https://python-chess.readthedocs.io/en/latest/core.html#chess.Termination.SEVENTYFIVE_MOVES https://python-chess.readthedocs.io/en/latest/_modules/chess.html#Board.outcome (under "automatic draws")

Additionally, Lichess (via scalachess) supports fivefold repetition (but not 75-move rule, 50-move auto draws):

https://github.com/ornicar/scalachess/search?q=fivefold

It's funny, about the recency of the rules: even though they were implemented in 2014 which is 7 years ago, in terms of the history of chess, that might as well have been yesterday :) So I get that as well.

We will need to think about variants - I figured that most western chess variants (armageddon, crazyhouse, etc) adopt the drawing rules unless they explicitly state that they don't. The harder part would be removing it from regional variants or variants that don't derive from western chess, if it doesn't make sense to apply the rules there.

Thank you for your input! Maybe if I feel like it, I may create a PR that you can review, and if so we can discuss more then.