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
617 stars 194 forks source link

Multimove variants #343

Open mehmet-ismail opened 3 years ago

mehmet-ismail commented 3 years ago

The standard chess sequence can be written as WB/WB/WB... (the slashes separate alternating pairs of moves). "Balanced Alternation" proposes the following move sequence: After White’s (W) initial move, first Black (B) and then White each have two moves in a row (BBWW), followed by the usual alternating sequence, beginning with W, which altogether can be written as WB/BW/WB/WB/WB…. Except for reversal of the 3rd and 4th moves from WB to BW (bold), this is the standard chess sequence.

There are two restrictions: A player can check or capture a piece only on the second move of a double move to ensure that the opponent can respond to it. In other words, a player can neither give a check nor capture a piece in the first move of a double move. (For example, White cannot use the double move to check and then capture the opponent’s King.)

This is from a recently published paper Brams and Ismail available at https://ieee-cog.org/2021/assets/papers/paper_230.pdf

ianfab commented 3 years ago

Thanks for your suggestion and for the reference.

Any changes to the move sequence, whether it is multi moves or alternating order, unfortunately is very problematic for (Fairy-)Stockfish, since the alternating color of moves is implicitly assumed in both the position representation, as well as the search algorithm (due to the negamax approach in the alpha-beta search). Therefore I think for such a variant it would make more sense to start a separate fork directly from official Stockfish, since the support of many variants just adds to the complexity, and the alternation of moves can not really benefit from any of the existing variant code, so I do not think it is practicable to include it in this project.

Edit: I almost forgot, but I actually also have the design related contraints covered to some extent in the FAQs: https://github.com/ianfab/Fairy-Stockfish/wiki/FAQ#can-the-gamevariant-xyz-be-supported

mehmet-ismail commented 3 years ago

Thanks for your response. I see now that you've already posted what can't be done in the FAQs. Sorry I haven't seen it.

So the variants such as Marseillas Chess https://en.wikipedia.org/wiki/Marseillais_chess is also out I guess. Another interesting variant is "n+1" chess in which White 1 makes 1 move, then Black makes 2 moves in a row, and then White makes 3 moves etc. until the game ends.

It looks like the main issue is that the alternating issue is implicitly assumed in a couple of places such as the alpha-beta search. And then I guess one would need to define an order function to generalize it (if that works). Anyway, thank you very much and good luck with your project!

ianfab commented 3 years ago

Yes, unfortunately similar variants like Marseillais and Progressive are also out of scope.

As you mentioned, the search algorithm would need to be adapted or redesigned entirely. Arimaa might be an interesting game to look into to compare how engine search algorithms evolved over time there, because it also has the challenge that the side to move does not switch after every move. https://arxiv.org/pdf/1403.6154.pdf also is somewhat related.

Overall multimove variants definitely are an interesting topic to explore, but since I currently consider multimove variants as too big of a change to incorporate in this project, I will close this issue for now.

ianfab commented 3 years ago

Reopening to investigate a potential workaround using passing moves...

phoe commented 8 months ago

I see that 82dab6567 mentions "closes #343" - is this the case?

ianfab commented 8 months ago

This is just on a branch and not merged to master. Technically it would close this issue, but it is just a workaround to make multimove variants possible using passing moves, a proper support is out of scope.