Check out Symmetric Chess, our featured variant for March, 2024.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Single Comment

Chess. Play Chess with Jocly.[All Comments] [Add Comment or Rating]
📝Michel Gutierrez wrote on Mon, Apr 18, 2016 09:50 AM UTC:
<p>The documentation on the API is available on the <a href="http://wiki.jocly.com/index.php/Jocly_Basics">Wiki</a>.</p> <p>This being said, the documentation describes the general interface to put a game in Jocly, but your questions are more oriented towards the <i>chessbase</i> module implementation, which is one the 30 or 40 game modules available (but this is the biggest one in terms of code).</p> <p>We do not have a precise documentation on the <i>chessbase</i> module, most of it resides in the code and in the ~50 chess games that have been implemented. As you certainly found out, you can access all of the code from <a href="https://jocly.com/jocly/plazza/inspector">the jocly source code inspector</a>. You should have a close look at <code>base-model.js</code> which implements everything all the chess games have in common.</p> <p>To answer some of your questions:</p> <p>The <code>Move</code> object may have the following fields:</p> <ul> <li><code>f</code> the starting position of the piece</li> <li><code>t</code> the ending position</li> <li><code>c</code> the position of the piece being captured, if any</li> <li><code>pr</code> the piece type that is promoted to if any</li> <li><code>cg</code> the init position of the piece (other than the king) that is involved in a castle, if any</li> <li><code>ck</code> whether the move leads to a check</li> </ul> <p>The <code>Board</code> object have the following fields (not exhaustive):</p> <ul> <li><code>board</code> an array that maps positions to pieces</li> <li><code>pieces</code> an array containing all the pieces in the game</li> </ul> <p>Each element of the array <code>Board.pieces</code> implements the fields:</p> <ul> <li><code>s</code> the side of the piece, 1/-1 for white/black</li> <li><code>p</code> the position of the piece. If -1, the piece is not on the board (probably captured).</li> <li><code>t</code> the piece type</li> <li><code>i</code> a unique index for the piece</li> <li><code>m</code> whether that piece has already moved in the game</li> </ul> <p>It is very important that <code>Board.board</code> and <code>Board.pieces[xx].p</code> are always consistent. You can call <code>Board.cbIntegrity</code> during your development to ensure the whole board is consistent (remove it for production as it takes too much CPU). So you can add a piece by modifying both <code>Board.board</code> and <code>Board.pieces</code>.</p> <p>You can know whose turn it is from <code>Board.mWho</code> (1 or -1).</p> <p>You can know the last move from <code>Board.lastMove</code> but this is rarely used, like for instance to implement "en passant" capture.</p> <p>You can know a position is empty with <code>Board.board[pos]<0</code>.</p> <p>If you want to somehow remove some positions from the board, there are several approaches.<p> <ul> <li>You can overload GenerateMoves to remove from the legacy moves, the ones that end in a disabled position.</li> <li>You can define the piece move generation to "confine" to a number of acceptable positions.</li> </ul> <p>Have a look at the XiangQi implementation where some pieces are restrained to a part of the board.</p> <p>A few tips when you develop a game:</p> <ul> <li>do so in self vs self mode, otherwise the AI makes many calls that cannot really be controlled</li> <li>use the browser console and debugger. Adding instruction <code>debugger</code> in the code stops the execution and enters the debugger to examine the stack and data.</li> <li>do not lose faith, it always work in the end :)</li> </ul>