aclap-dev / jocly

Javascript library and tools to provide user interface (2D, 3D, VR) and engine for playing board games
https://jocly.com/
Other
71 stars 28 forks source link

How to set create a match with a specified initial state? #33

Closed ngocdaothanh closed 6 years ago

ngocdaothanh commented 6 years ago

https://github.com/mi-g/jocly/wiki/Match-API-Object says that there are methods getBoardState and getInitialBoardState.

But how to set board initial state?

For example, Chess960 has 960 initial states. How can I create a match with a specified FEN?

mi-g commented 6 years ago

There are 2 ways to do so.

1/ providing the list of moves that lead to the board state 2/ providing the initial board state directly

This can also be combined: start a game with an initial board state then a number of moves afterwards.

Either way, this is done through the load() method, passing an object with property playedMoves describing the moves, initialBoard for the static starting board state. You can find an example of this here.

Note that only some games support initialBoard, namely the Chess variants using the FEN notation, and Checkers variants.

ngocdaothanh commented 6 years ago

Thanks!

I intended to edit the wiki page to add the info to getInitialBoardState, but I couldn't find the edit button, so @mi-g please edit it.