Answers.Body: <p><a href="https://github.com/ianfab/Fairy-Stockfish" rel="nofollow noreferrer">Fairy-Stockfish</a> supports configuration of chess variants at runtime, and it also has bindings for Python (pyffish) and Javascript (ffishjs) which can be used as libraries for chess variant game logic. E.g., <a href="https://www.pychess.org/" rel="nofollow noreferrer">PyChess</a> has very few game logic built in, and uses both bindings in backend and frontend for the variant rules.</p>
  <p>If you do not want to build something on your own, <a href="https://chesscraft.ca/" rel="nofollow noreferrer">ChessCraft</a> might be an alternative to be able to define and play variants directly in a UI.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-28T16:11:57.480Z
Answers.Text: Thank you a lot for providing that reference. I was not aware that there exist Fairy-Stockfish, and the Javascript compilation seems to be what I need. I will give it a try, but this seems to be a nearly perfect fit.
Answers.UserDisplayName: mliebelt
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-29T17:01:27.350Z
Answers.Text: I had a more detailed look, and boy, that is complicated. I am not sure that using ffish i with Javascript bindings is the way to go. But I don't expect any better tip, therefore I will accept the answer. What is difficult for me: possible to use in the browser?; bloated library with way more functionality than I need (other strategic games, engine, ...); API does not fit best, but should work; configuration in file. But plus is: configuration rules explicit (to learn and steal from); sufficient interface for playing.
Answers.UserDisplayName: mliebelt
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-28T11:56:57.163Z
Answers.LastActivityDate: 2020-11-28T11:56:57.163Z
Answers.UserDisplayName: Fabian Fichter
Body: <p>In Corona times, it is not so easy to train children over the board. When that was possible, we used a lot of mini games with fewer pieces and most of the times a different goal. To bring those mini games online is not so easy, due to many factors:</p>
  <ul>
  <li>Known chess libraries like <code>chess.js</code> (the most used Javascript library for chess) only allows standard games and does not support mini games.</li>
  <li>Chess online sites like lichess.org have their set of games possible, and it is not at all easy to expand that.</li>
  <li>Children should have a very simple web interface to start a game, play it, ...</li>
  </ul>
  <p>So I am thinking about creating something myself. I am sure I can come up with a simple web application to register, pair players, ..., but the hardest part (for me) is to check that the rules of chess are met. But this set of rules is not fixed. Here are some examples</p>
  <ul>
  <li>Some mini games don't have kings at all. This is not allowed in standard chess.</li>
  <li>Some mini games treat the kings like normal pieces, so there is no chess, or even kings can be beaten.</li>
  <li>Some mini games define the end of the game when the first piece is beaten. Or a pawn is promoted.</li>
  <li>One variant I know has as rule that knight moves as knight, but captures as bishop, and vice versae.</li>
  <li>Some mini games are played on different sized boards.</li>
  <li>Some place pieces, that are not allowed to moved and / or captured.</li>
  </ul>
  <p>What I am looking for is a library (preferred Javascript) that allows to add easily additional rules, and define for each game which rules are mandatory. Do you have recommendations about this?</p>
  
Tags: <programming>
Title: Library to program mini games
ThreadText: # Library to program mini games
  
  (Asked by: username_0 on 2020-11-28)
  
  In Corona times, it is not so easy to train children over the board. When that was possible, we used a lot of mini games with fewer pieces and most of the times a different goal. To bring those mini games online is not so easy, due to many factors:
  
  * Known chess libraries like `chess.js` (the most used Javascript library for chess) only allows standard games and does not support mini games.
  * Chess online sites like lichess.org have their set of games possible, and it is not at all easy to expand that.
  * Children should have a very simple web interface to start a game, play it, ...
  
  So I am thinking about creating something myself. I am sure I can come up with a simple web application to register, pair players, ..., but the hardest part (for me) is to check that the rules of chess are met. But this set of rules is not fixed. Here are some examples
  
  * Some mini games don't have kings at all. This is not allowed in standard chess.
  * Some mini games treat the kings like normal pieces, so there is no chess, or even kings can be beaten.
  * Some mini games define the end of the game when the first piece is beaten. Or a pawn is promoted.
  * One variant I know has as rule that knight moves as knight, but captures as bishop, and vice versae.
  * Some mini games are played on different sized boards.
  * Some place pieces, that are not allowed to moved and / or captured.
  
  What I am looking for is a library (preferred Javascript) that allows to add easily additional rules, and define for each game which rules are mandatory. Do you have recommendations about this?
  
  **Tags:** programming
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-11-28. Score: 2 | Accepted answer
  
  [Fairy-Stockfish](https://github.com/ianfab/Fairy-Stockfish) supports configuration of chess variants at runtime, and it also has bindings for Python (pyffish) and Javascript (ffishjs) which can be used as libraries for chess variant game logic. E.g., [PyChess](https://www.pychess.org/) has very few game logic built in, and uses both bindings in backend and frontend for the variant rules.
  
  If you do not want to build something on your own, [ChessCraft](https://chesscraft.ca/) might be an alternative to be able to define and play variants directly in a UI.
  
  > **Comments:**
  > **username_0**: Thank you a lot for providing that reference. I was not aware that there exist Fairy-Stockfish, and the Javascript compilation seems to be what I need. I will give it a try, but this seems to be a nearly perfect fit.  
  > **username_0**: I had a more detailed look, and boy, that is complicated. I am not sure that using ffish i with Javascript bindings is the way to go. But I don't expect any better tip, therefore I will accept the answer. What is difficult for me: possible to use in the browser?; bloated library with way more functionality than I need (other strategic games, engine, ...); API does not fit best, but should work; configuration in file. But plus is: configuration rules explicit (to learn and steal from); sufficient interface for playing.  
  
  ---
  
  