You are on the backup site for Chessvariants.com. Any posts, moves, or other changes you make here will not be permanent, because the pages and database from the main site will be backed up here every midnight EST. Additionally, things may not be working right, because this site is also a testbed for newer system software. So, if you are not here to test, develop, or merely read this site, you may want to change .org to .com in the navigation bar and go to the main site.



The Chess Variant Pages




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

Comments/Ratings for a Single Item

Later Reverse Order EarlierEarliest
Chess. Play Chess with Jocly.[All Comments] [Add Comment or Rating]
Fergus Duniho wrote on 2017-04-11 UTC

I replied to your email yesterday morning, and I've been waiting for you to reply since then. I'm unfamiliar with the use of git, and the instructions seem to assume that I can send terminal commands to my website, but all I have is cpanel access. So I need further instructions on how to proceed.


Michel Gutierrez wrote on 2017-04-11 UTC

Fergus, there is now a much better way to integrate Jocly games into a site. Can you reply to my mails ?


Michel Gutierrez wrote on 2016-04-22 UTC
<p>Forget about <code>Model.Game.cbRoyalLongRangeGraph</code>, that's really not want you want to do. These <code>cb...RangeGraph</code> functions generate a static graph for a single piece on an empty board.</p> <p>The unusual move here is having the King (yeah, the Queen-dressed one) moving long range, but unable to pass through a check position.</p> <p>You should:</p> <ul> <li>define an empty graph for the king, so it does not make core-generated moves</li> <li>overwrite the <code>Board.GenerateMoves</code> function to <ol> <li>call the original <code>Board.GenerateMoves</code> to generate all (but King's) legacy moves</li> <li>add the King's moves manually</li> </ol> </li></ul> <p>To overwrite <code>Board.GenerateMoves</code>:</p> <p></p><pre>var SuperModelBoardGenerateMoves=Model.Board.GenerateMoves; Model.Board.GenerateMoves = function(aGame) { SuperModelBoardGenerateMoves.apply(this,arguments); // add extra moves with this.mMoves.push(...) } </pre><p></p> <p>To generate manually the king's moves, look at <code>base-model.js</code> function <code>Board.GeneratePseudoLegalMoves</code>, lines 798-850. This shows how to walk through the graph for long range movements, following <em>directions</em> (called <code>lines</code> here). This is where you can verify that each single position crossed is not in check (by calling <code>Board.cbGetAttackers</code>). If it is, just break out the loop to stop considering the line.</p> <p>Have a look at the Metamachy model file. The special castle implementation is not that far from what you want to achieve here.</p>

Fergus Duniho wrote on 2016-04-22 UTC
> forget about the Queen from a programming point of view: this is definitely a King

I already have "isKing" set to true in the definition of the piece, but this does not stop the Queen from moving through check. Unlike the King, the Queen moves any number of spaces, and the code for the King isn't taking that into account. Maybe I should modify Model.Board.Evaluate.

> have a look at the XiangQi implementation, there is something about preventing Kings to face each other

That's already handled.

Michel Gutierrez wrote on 2016-04-22 UTC
<p>I'm not sure you are taking the right approach here.</p> <p>In Chess in general and in the Jocly implementation in particular, the king has a special status and has a lot of code associated to that status. Meaning, if your game defines the Queen has being the piece to checkmate, you should treat it as the King in the implementation. Believe me, you'll save yourself a lot of troubles.</p> <p><code>cbLongRangeGraph</code> is a function to calculate once for all (it's only done at the beginning of the game) a big array to store the general movement graph for each piece type. There is no way it takes into account dynamic situations like check.</p> <p>Functions are located in <code>Board</code> or <code>Game</code> for good reasons: they don't have the same visibility of the gaming situation and attempting to move a function from one class to another will almost always fail.</p> <p>When the page stays blank, this is generally a problem with the code syntax or top level execution. You should look at the console, there is a trace saying that <code>Board is undefined</code> somewhere.</p> <p>My recommandations:<p> <ul> <li>forget about the Queen from a programming point of view: this is definitely a King</li> <li>have a look at the XiangQi implementation, there is something about preventing Kings to face each other</li> </ul>

Fergus Duniho wrote on 2016-04-22 UTC
<P>Michel,</P> <P>I'm currently working on <A HREF="http://play.chessvariants.com/jocly/britannia.html">Caïssa Britannia</a>, and it is mostly working except that I haven't figured out how to code the Queen's movement to prevent it from moving through check. I have seen the cbGetAttackers method being used to test whether the King was in check, and I've plugged that into a modified version of cbLongRangeGraph called cbRoyalLongRangeGraph, but so far I've just been getting a white screen when I add it in. I think one of the issues is that I've seen it used in Model.Board methods, but I'm trying to use it in a Model.Game method. Is there a right way for me to use it in a modified copy of Model.Game.cbLongRangeGraph?</P>

jcfrog choain wrote on 2016-04-21 UTC
UV unwrapping is a complicated issue. There is no automatic procedure which works for every mesh.
Of course there are a lot of tutorials on the web about unwrapping UVs, it needs a bit of practice.
Nevertheless, in Blender, for simples meshes, you can try automatic unwrapping. This will lead to a first result you will be able to modify.
For a better result, you can mark seams that will help to cut big parts so that you can process them separately.
Remember UV maps and textures are linked, if you modify it, you'll have to rebake or modify the textures accordingly.
A vast issue, not easy to help you with a few words.

Fergus Duniho wrote on 2016-04-20 UTC
Thanks, Jerome.

I am completely inexperienced with Blender, and I have only just started trying to learn how to use it to make some more 3D pieces for Jocly. While researching what texture baking is, I came across something called UV unwrapping, which is basically translating a 3D object to a 2D map. Given what the maps for the Staunton pieces looked like when I viewed them, it looks like that is what is going on. Is there a way to automatically unwrap a 3D object? Or do I have to do it manually? As something to work with, I downloaded an alternate Chess Knight and imported it into Blender, but I'm not sure what to do next.

jcfrog choain wrote on 2016-04-20 UTC
Hi,

I used to work on Jocly with Michel.

Fergus, talking about the blender export issue, the threejs exporter will actually produce only a JS file which includes the mesh and some additional  info like the UVs maps or some material settings.

I guess you were expecting the diffuse and normal maps. The exporter can't do this.

These maps are produced separately. There are a few possible methods but I used the texture baking. 

Hope it helps. I will follow this thread, if you have questions...

jerome

Fergus Duniho wrote on 2016-04-20 UTC
I noticed that some of the code between a less-than sign and a greater-than sign is not showing up. But if you view the page source, you will see it.

Michel Gutierrez wrote on 2016-04-20 UTC
Very good, thanks !

Fergus Duniho wrote on 2016-04-20 UTC
<P>Michel,</P> <P>Thanks to your suggestion on how to fix the bug in Grand Chess, I fixed the bug in both <A HREF="http://play.chessvariants.com/grandchess.html">Grand Chess</A> and <A HREF="http://play.chessvariants.com/grandcavalier.html">Grand Cavalier Chess</A>. I did it a little differently, though. I began by creating an array of the maximum number of each piece that may be on the board. As I found each piece belonging to the same side as the player, I decremented its count in the array. Then, for any left in the array with counts above zero, I made an array of pieces that may be promoted to. Here is the new <CODE>promote</CODE> function for Grand Chess. You may use it in your version:</P> <PRE> // Bug-fixed by Fergus Duniho promote: function(aGame,piece,move) { if(piece.t==1) return [0]; else if(piece.t==3) return [2]; var r=geometry.R(move.t); if((piece.t==0 && r<=9 && r>=7) || (piece.t==2 && r>=0 && r<=2)) { var considerTypes={ 4:2, 5:2, 6:2, 7:1, 9:1, 10:1 }; for(var i=0;i<this.pieces.length;i++) { var piece1=this.pieces[i]; if(piece1.s==piece.s // piece from our side && piece1.p>=0 // in play on board && (piece1.t in considerTypes)) // promotable piece type considerTypes[piece1.t] = considerTypes[piece1.t] - 1; } var promo=[]; for(var t in considerTypes) { // create an array of types from our types map if (considerTypes[t] > 0) promo.push(t); } if(r!=0 && r!=9) { promo.unshift(piece.t); } else if(promo.length==0) return null; // last line but no captured piece to promote to: move is not possible return promo; } return []; }, </PRE>

Michel Gutierrez wrote on 2016-04-19 UTC
<p>The <code>Board.board[pos]</code> value is the index of the piece you will find in <code>Board.pieces</code>. For instance, if there is a piece at position <code>pos</code> (<code>board.board[pos] >= 0</code>), then <code>board.pieces[board.board[pos]].p</code> is always equal to <code>pos</code>.</p> <p>Regarding the promotion in Grand Chess, we indeed just verify there is a piece of the type that has been captured at some point. Whether we had promotions to that type is not considered. We should instead count the number of pieces in play for each type, and offer promotion to that type if this is not already the maximum. That should be easy to fix. Good catch !</p> <p>About <code>debugger;</code>, make sure the developer tools are open otherwise the instruction does not do anything.</p> <p>I'm afraid i cannot tell much about the three.js 3D generation, that was Jerome's area and he is currently busy with other stuff. I'll see with him if he can give some explanations.</p>

Fergus Duniho wrote on 2016-04-19 UTC
<P>Michel,</P> <P>Thanks for the information. It should prove helpful. One thing you didn't mention was the object for a board space and its properties. Should I understand that board.board[pos] will just return the piece on it and nothing more?</P> <P>While testing code for <A HREF="http://play.chessvariants.com/jocly/grandcavalier.html">Grand Cavalier Chess</A>, I found a bug that is also shared by <A HREF="http://history.chess.free.fr/jocly/grandchess/jocly-grandchess.html">Grand Chess</A>. Both games limit promotion to captured pieces, and because Grand Cavalier Chess borrows the rule from Grand Chess, I adapted its <CODE>promote</CODE> function. The bug is that once a piece of a certain type has been captured, promotion is allowed to that piece type multiple times. Playing Grand Chess with myself, I currently have three white Marshalls on the board. But by the rules of the game, there should never be more than one. One possible way to fix this is to demote a captured piece to a Pawn when a Pawn promotes to it, though I'm not sure how to do that. Game Courier enforces this rule by counting pieces as they are captured and decrementing the appropriate count when a promotion happens.</P> <P>Also, I inserted <CODE>debugger</CODE> at the end of the model for Grand Cavalier Chess, but it is not doing anything. Is there a right way to use it that I'm missing?</P> <P>One more thing. I have installed the three.js exporter into Blender, but the documentation you have on using it to export two maps and a .js file doesn't match the options it currently gives me, and all I've exported so far is a single .json file.</P>

Carlos Cetina wrote on 2016-04-19 UTC
You are welcome. OK, don't worry, I understand. Hopefully such developers appear, arise, come up!

Michel Gutierrez wrote on 2016-04-18 UTC
Carlos, thanks for the idea, those games look very interesting.

Unfortunately, we won't have time any more for implementing new games on our own for the foreseeable future. I hope we'll find chess variants enthusiasts developers to help there.

Carlos Cetina wrote on 2016-04-18 UTC
Michel: <p> I have recently signed up on <a href="https://www.jocly.com/#/about">Jocly</a> with the same userid that I use here (sissa) and would like to suggest you to implement two games: <a href="http://www.chessvariants.com/invention/symmetric-chess">Symmetric Chess</a> and Gabriel Maura's <a href="http://www.chessvariants.com/large.dir/omega.html">Omega Chess</a>, so the number of games available at Jocly would be... 115! <p> Unfortunately, in programming I am completely ignorant, so I have no way to help. If you and Jérôme can do it and think such games are interesting, good; if not, no problem; anyway I will follow enjoying playing in your server.

Michel Gutierrez wrote on 2016-04-18 UTC
<p>By the way, we have implemented long ago a specific board geometry to play on a cube (in fact it's a NxMxP geometry where you can configure any of the 3 dimensions), but since we were lacking rules, no game has ever been released on this. As a consequence, the <a href="https://jocly.com/jocly/plazza/inspector#/">source inspector</a> does not offer the corresponding files (since you first select a game to access its source code). If anyone is interested in inventing rules, i can send the base source code.</p>

Michel Gutierrez wrote on 2016-04-18 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>

Fergus Duniho wrote on 2016-04-18 UTC
Thanks, I tried different colors and eventually found one I was happy with. Now that it clearly displays legal moves and has the three-color pattern for better visualizing Nightrider moves, I was able to easily beat it at its 1 second strength. Prior to this, it was beating me, because I couldn't see the position as well as the computer could.

I have been looking over the code to better learn how Jocly works, and I have some general questions about available data and basic procedures that can help me program other games. I gather that move.f is the position a piece has moved from, move.t is the space it has moved to, and piece.t is the piece type. What about any other move.* or piece.* values? What are they and what information do they return? What about other objects with important data? How would I find out the last piece moved, what is on a particular space, whether a piece has been captured and what it is, whether a particular space is empty, what turn it is, and which side is moving?

Moving to procedures. How would I add an arbitrary piece to a space? How would I empty a space? Is there a way to delete a space, so that it is no longer considered part of the board? Or, if not, is there another way to isolate areas of the board from each other?

Michel Gutierrez wrote on 2016-04-16 UTC
In the view, just do something like <code>View.Game.cbTargetSelectColor = 0xff8800;</code>

Fergus Duniho wrote on 2016-04-16 UTC
Okay, I made the two dark colors different primary colors. Do you know how I could change the color of the markers used to identify legal moves? They show up well on dark spaces, but they don't show up nearly as well on the light spaces.

Michel Gutierrez wrote on 2016-04-16 UTC
Great !

In my opinion, you should differentiate a bit more the 2 3D dark colors. It took me 10 minutes to figure out why it was not working in 3D while it was, even using a high quality monitor.

Fergus Duniho wrote on 2016-04-16 UTC
Thanks. This worked. The colors I picked worked well enough for 2D, but I changed the colors for 3D. The board uses two different colors for the dark squares, alternating them by rank and file, to help in the visualization of Nightrider moves.

Michel Gutierrez wrote on 2016-04-15 UTC
<p>Because the mail has a javascript file in attachment, it may be filtered out by some malware trackers. Since the file is short, i copy it here.<p> <p><pre> (function() { View.Game.cbPromoSize = 1200; View.Game.cbDefineView = function() { var orthoBoardDelta = { // notationMode: 'in', // notationDebug: true, }; var threeColors = { 'colorFill' : { "+": "rgba(128,128,0,1)", // Added by Fergus Duniho ".": "rgba(189,183,107,1)", // "white" cells "#": "rgba(85,107,47,1)", // "black" cells } } var orthoBoard3d = $.extend(true,{},this.cbGridBoardClassic3DMargin,orthoBoardDelta,threeColors); var orthoBoard2d = $.extend(true,{},this.cbGridBoardClassic2DNoMargin,orthoBoardDelta,threeColors); return { coords: { "2d": this.cbGridBoard.coordsFn.call(this,orthoBoard2d), "3d": this.cbGridBoard.coordsFn.call(this,orthoBoard3d), }, boardLayout: [ ".#+.#+.#", "#+.#+.#+", "+.#+.#+.", ".#+.#+.#", "#+.#+.#+", "+.#+.#+.", ".#+.#+.#", "#+.#+.#+", ], board: { "2d": { draw: this.cbDrawBoardFn(orthoBoard2d), }, "3d": { display: this.cbDisplayBoardFn(orthoBoard3d), }, }, clicker: { "2d": { width: 1400, height: 1400, }, "3d": { scale: [.75,.75,.75], }, }, pieces: this.cbFairyPieceStyle({ "default": { "2d":{ width: 1300, height: 1300, }, "3d": { scale: [.5,.5,.5], }, }, "fr-knight": { "3d": { scale: [.4,.4,.4], rotate: 90, }, }, "fr-unicorn": { "3d" : { rotate: 90, }, }, }), }; } /* Make the knighted pieces jump when leaping */ View.Board.cbMoveMidZ = function(aGame,aMove,zFrom,zTo) { var geometry = aGame.cbVar.geometry; var x0 = geometry.C(aMove.f); var x1 = geometry.C(aMove.t); var y0 = geometry.R(aMove.f); var y1 = geometry.R(aMove.t); if(x1-x0==0 || y1-y0==0 || Math.abs(x1-x0)==Math.abs(y1-y0)) return (zFrom+zTo)/2; else return Math.max(zFrom,zTo)+1500; } })(); </pre></p>

25 comments displayed

Later Reverse Order EarlierEarliest

Permalink to the exact comments currently displayed.