Check out Grant Acedrex, our featured variant for April, 2024.

Enter Your Reply

The Comment You're Replying To
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>

Edit Form

Comment on the page Chess

Conduct Guidelines
This is a Chess variants website, not a general forum.
Please limit your comments to Chess variants or the operation of this site.
Keep this website a safe space for Chess variant hobbyists of all stripes.
Because we want people to feel comfortable here no matter what their political or religious beliefs might be, we ask you to avoid discussing politics, religion, or other controversial subjects here. No matter how passionately you feel about any of these subjects, just take it someplace else.
Quick Markdown Guide

By default, new comments may be entered as Markdown, simple markup syntax designed to be readable and not look like markup. Comments stored as Markdown will be converted to HTML by Parsedown before displaying them. This follows the Github Flavored Markdown Spec with support for Markdown Extra. For a good overview of Markdown in general, check out the Markdown Guide. Here is a quick comparison of some commonly used Markdown with the rendered result:

Top level header: <H1>

Block quote

Second paragraph in block quote

First Paragraph of response. Italics, bold, and bold italics.

Second Paragraph after blank line. Here is some HTML code mixed in with the Markdown, and here is the same <U>HTML code</U> enclosed by backticks.

Secondary Header: <H2>

  • Unordered list item
  • Second unordered list item
  • New unordered list
    • Nested list item

Third Level header <H3>

  1. An ordered list item.
  2. A second ordered list item with the same number.
  3. A third ordered list item.
Here is some preformatted text.
  This line begins with some indentation.
    This begins with even more indentation.
And this line has no indentation.

Alt text for a graphic image

A definition list
A list of terms, each with one or more definitions following it.
An HTML construct using the tags <DL>, <DT> and <DD>.
A term
Its definition after a colon.
A second definition.
A third definition.
Another term following a blank line
The definition of that term.