Check out Grant Acedrex, our featured variant for April, 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 ]

Comments/Ratings for a Single Item

Earlier Reverse Order Later
Chess. Play Chess with Jocly.[All Comments] [Add Comment or Rating]
🕸Fergus Duniho wrote on Tue, Apr 5, 2016 04:36 PM UTC:
I put this page up, but I credited the developers of Jocly, because I simply pasted their own code into this.

Chris Chradle wrote on Thu, Apr 7, 2016 03:42 AM UTC:
I thing castling doesn't work.

📝Michel Gutierrez wrote on Thu, Apr 7, 2016 09:42 AM UTC:
Thanks Fergus.

Chris: to castle, click the king then the rook. It's uncommon (one generally clicks on the king's target square), but this method allows to solve castling ambiguities with some variants.

🕸Fergus Duniho wrote on Thu, Apr 7, 2016 07:10 PM UTC:
<P>Michel,</P> <P>Is there any way to handle multiple castling options on each side? I am trying to program <A HREF="/play/jocly/grotesque.html">Grotesque Chess</A>, but I can't get the castling to work right.</P> <P>This didn't work at all:</P> <PRE> castle: { "4/1": {k:[3,2,1],r:[1,2],n:"Kb1"}, "4/2": {k:[3,2],r:[1,2,3],n:"Kc1"}, "4/6": {k:[5,6],r:[8,7,6,5],n:"Kg1"}, "4/7": {k:[5,6,7],r:[8,7,6],n:"Kh1"}, "4/8": {k:[5,6,7,8],r:[8,7],n:"Ki1"}, "74/72": {k:[73,72,71],r:[71,72],n:"Kb8"}, "74/73": {k:[73,72],r:[71,72,73],n:"Kc8"}, "74/76": {k:[75,76],r:[78,77,76,75],n:"Kg8"}, "74/77": {k:[75,76,77],r:[78,77,76],n:"Kh8"}, "74/78": {k:[75,76,77,78],r:[78,77],n:"Ki8"}, }, </PRE> <P>This works only for the last one assigned to an initial value. So, for example, castling white King-side moves the King to i1 and the Rook to h1 without providing any options.</P> <PRE> castle: { "4/0": {k:[3,2,1],r:[1,2],n:"Kb1"}, "4/0": {k:[3,2],r:[1,2,3],n:"Kc1"}, "4/9": {k:[5,6],r:[8,7,6,5],n:"Kg1"}, "4/9": {k:[5,6,7],r:[8,7,6],n:"Kh1"}, "4/9": {k:[5,6,7,8],r:[8,7],n:"Ki1"}, "74/70": {k:[73,72,71],r:[71,72],n:"Kb8"}, "74/70": {k:[73,72],r:[71,72,73],n:"Kc8"}, "74/79": {k:[75,76],r:[78,77,76,75],n:"Kg8"}, "74/79": {k:[75,76,77],r:[78,77,76],n:"Kh8"}, "74/79": {k:[75,76,77,78],r:[78,77],n:"Ki8"}, }, </PRE>

📝Michel Gutierrez wrote on Thu, Apr 7, 2016 10:43 PM UTC:
<p>Fergus,</p> <p>No, you cannot do that using the standard castling declaration, with an object with keys matching king-position/rook-position. Note that having twice the same key won't work by nature of the javascript language.</p> <p>However, you should have a look at the Jocly implementation of Wildebeest. This is (almost?) exactly the same case. It has been solved by defining a "normal" castle by declaration, and adding other castle possibilities "manually". You should be able to copy/paste from wildebeest-model.js lines 188 to 326.</p>

🕸Fergus Duniho wrote on Sat, Apr 9, 2016 06:53 PM UTC:
Thanks, Michel. I got Grotesque Chess programmed. The one glitch is that I couldn't get it to work without including both styles of castling. Unlike Wildebeest Chess, Grotesque Chess doesn't let the King castle by moving one space. So I had no use for moving the King to the Rook's space, but when I left out the code for that, no castling worked. So I put it back in and mapped it to castling moves that were already covered by moving the King to an empty space. I have thought of studying the base model to figure out how I could rewrite the code for castling, but even with my experience programming the rules of Chess multiple times in my own language, it's still hard to follow. Is there any documentation on the base model for Chess?

📝Michel Gutierrez wrote on Sat, Apr 9, 2016 11:03 PM UTC:
<p>Congratulations on your implementation !</p> <p>We have an API documentation of the model on the <a href="http://wiki.jocly.com/">Jocly wiki</a> but it's for the games in general. Unfortunately, we do not have something specific to the base chess implementation.</p> <p>I did not try this myself but i would see 2 different ways to solve the issue of having twice the same castle move defined (with my apologies if you trued that and it didn't work):</p> <p>1/ do not define the "normal" castling definition. You say when you leave it out there was no castling possible. Did you try to set "castle" as an empty object ( castle: {} ) or to just remove the "castle" key (the second might not work).</p> <p>2/ do not define, in the extra castle moves, the one that is already covered by the regular castle definition. That would certainly lead to (just focusing on white left castle):</p> <p><code> var extraCastle={ 0:{k:[2],r:[3]}, ... </code></p> <p>and</p> <p><code> Model.Game.wbExtraCastleRook={ 2:{r0:0,r:3}, ... </code></p>

🕸Fergus Duniho wrote on Sun, Apr 10, 2016 03:39 PM UTC:
<P>So that I don't interfere with people playing Grotesque Chess, I have been trying things with <A HREF="/play/jocly/univers.html">Univers Chess</A>, which has the same castling rule.</P> <P>Setting castle to {} and removing "castle: true," from the Rook's definition both completely disabled castling. Removing castling moves from extraCastle would eliminate the duplication, but it would leave the game with two different methods for castling. My aim is to use the same method of castling for all castling moves.</P> <P>Looking at the base model for Chess, it looked like Model.Board.cbGeneratePseudoLegalMoves would be a suitable method to modify, but simply including it in the custom model without any modification has the effect of disabling all moves. To check whether the code I got from the Jocly Game Inspector was up-to-date, I used Firebug to look at the code it loaded from the base model, and nothing was different. </P> <P>As a further test, I copied Model.Board.cbApplyCastle into my custom model, and it didn't hurt anything.</P>

📝Michel Gutierrez wrote on Sun, Apr 10, 2016 05:23 PM UTC:
<p>Ok, i can see in the code why disabling regular castle also prevents extra castle. In the extra castle move generation, we first search for a regular castle move (which ensures king and rook haven't moved and there are only empty squares between them) before generating extra castle moves. If no regular castle, there is no extra castle.<p> <p>Another approach would be to keep the regular + truncated extra method, but change the UI (by overwriting the view js file like you did for the model) to always highlight the king target square and not the rook in case of a castle. In your <code>grotesque-custom-view.js</code> file, copy function <code>View.Board.xdInput</code> from <code>base-view.js</code>, and replace the line:<p> <p><code>var target = move.cg===undefined?move.t:move.cg;</code></p> <p>by</p> <p><code>var target = move.t;</code></p> <p>This has reasonable chances to work.</p>

🕸Fergus Duniho wrote on Sun, Apr 10, 2016 07:02 PM UTC:
<P>Thanks, I copied View.Board.xdInput to capachess-custom-view.js, made the one change, and it worked. While testing positions, I also learned that I need to define the regular castling moves as the shortest castling moves. When I had them defined as the longest castling moves, all castling moves on one side would be disabled if the longest one was illegal thanks to a space being attacked. Changing it to the shortest castling moves, I then tested whether castling to b1 would be legal if c1 were attacked, and it wasn't legal, which is good, but castling to d1 was still legal, which was also good. So it is working now, and it even changed how castling works in Capablanca's Chess. Now I just need to modify the regular castling in Grotesque Chess to use the shortest castling moves.</P>

📝Michel Gutierrez wrote on Sun, Apr 10, 2016 10:59 PM UTC:
Excellent work !

🕸Fergus Duniho wrote on Mon, Apr 11, 2016 09:22 PM UTC:
Is anyone else having trouble getting the Jocly scripts here to work right now? None of them are working for me right now.

📝Michel Gutierrez wrote on Mon, Apr 11, 2016 09:37 PM UTC:
Do you mean at <a href="/play/jocly/grotesque.html">this page</a> for instance ? It works well for me.

🕸Fergus Duniho wrote on Mon, Apr 11, 2016 09:56 PM UTC:
It's good to know that it is working for you. It is still not working for me. It may just be a temporary problem with internet connections. So I'll try again later.

📝Michel Gutierrez wrote on Mon, Apr 11, 2016 11:13 PM UTC:
Having a closer look, some pages work some don't.

My best guess is a jquery conflict between the version 1.10 you insert at the top of the page and version 1.6.2 that is inserted along with an ebay ad. I am not sure jquery.jocly.js would work with jquery 1.6.2.

🕸Fergus Duniho wrote on Mon, Apr 11, 2016 11:34 PM UTC:
Thanks for spotting that. I refreshed this page until a House of Staunton ad showed up, then it worked. I did recently enable more than in-house ads on these pages, and that is probably what made the difference. So I'll just program the header to not display ebay ads on Jocly pages.

🕸Fergus Duniho wrote on Wed, Apr 13, 2016 09:55 PM UTC:
<P>I programmed <A HREF="/play/jocly/cavalier.html">Cavalier Chess</A>, but the Cavaliers, which move the same as Chinese Chess Knights, are buggy. When I move one, it leaves an image of the piece on the space it moved from, and after Black moves only one or two times more, the game freezes up. The code I'm using for this piece is <CODE>Model.Game.cbHorseGraph(geometry)</CODE>, which is the same as the Xiangqi model uses for the Knight. <S>Also, is it possible to rescale individual piece types? I would like to scale the Cavaliers a little smaller, since they take the place of Pawns and are currently the same size as the Unicorn image I am using for the Nightrider.</S></P>

📝Michel Gutierrez wrote on Thu, Apr 14, 2016 03:49 PM UTC:
<p>Fergus,</p> <p>I had a quick look at your Cavalier Chess implementation and i saw a problem which is likely to cause the issue you are experiencing.</p> <p>You define a piece type for white cavalier:</p> <p><code> pieceTypes: { 0: { name: 'cavalier-w', aspect: 'fr-knight', graph: Model.Game.cbHorseGraph(geometry), value: 2, abbrev: 'H', initial: [{s:1,p:8},{s:1,p:9},{s:1,p:10},{s:1,p:11},{s:1,p:12},{s:1,p:13},{s:1,p:14},{s:1,p:15},{s:-1,p:48},{s:-1,p:49},{s:-1,p:50},{s:-1,p:51},{s:-1,p:52},{s:-1,p:53},{s:-1,p:54},{s:-1,p:55}], }, </code></p> <p>But you define initial position for both white and black, and you do the same for black cavalier. So basically there are 2 cavaliers at each 2nd second row, causing an exception in the code.</p> <p>I'm not sure about the Cavalier Chess rules but if the movements are the same for both sides, you should only have 1 piece type for the cavalier. If they don't have the same movement (like the regular pawns that go towards different directions), you must have 2 different piece types for black and white but ensure that the initial position is only defined for the corresponding side.</p> <p>Tip: when developing on Jocly, you should always have the browser console opened (F12) so that you can spot quickly when there is something wrong.</p>

🕸Fergus Duniho wrote on Thu, Apr 14, 2016 05:52 PM UTC:
Thanks, that makes perfect sense, and removing the wrongly placed Cavaliers fixed the problem. I defined the Cavalier twice, because each color promotes on a different rank.

📝Michel Gutierrez wrote on Fri, Apr 15, 2016 08:46 AM UTC:
Cavalier Chess looks very nice !

Just wondering, is it on purpose you set the knights and unicorns facing side instead of front ?

🕸Fergus Duniho wrote on Fri, Apr 15, 2016 03:50 PM UTC:
Thanks. I rotated the Knight and Unicorn images to show the horse head profile better, to better distinguish Cavaliers and Nightriders from each other, and to remind the player that these are not Chess Knights, which Jocly has normally been displaying in the face-forward orientation. Also, the 2D representation I have previously used for this game shows the same side view of these pieces.

I have been trying to change the colors of the spaces and make this a three-color board, as I usually use for this game, but so far I have been unsuccessful. I have changed the values of colorfill in View.Game.cbGridBoardClassic and View.Game.cbGridBoardClassic2D, but it has had no effect, and I don't see where else the color could be changed.

📝Michel Gutierrez wrote on Fri, Apr 15, 2016 04:49 PM UTC:
<p>Changing the board display shouldn't be too hard.</p> <p>Look at the customization of the Jocly implementation of courier chess. In file <code>courier-board-view.js</code>, you see an overwriting of the <code>colorFill</code> property. In a 3 colors board, you'll need to add a third symbol in addition to '.' and '#'. You'll also need to modify your existing <code>boardLayout</code> in <code>cavalier-custom-view.js</code> to place the cells as you wish using this third cell symbol.</p>

📝Michel Gutierrez wrote on Fri, Apr 15, 2016 05:11 PM UTC:
<p>Maybe i was not clear about where to do that in my previous comment. You should get something like:</p> <p><code> var orthoBoard3d = $.extend(true,{ 'colorFill' : { ".": "rgba(204,40,0,1)", "#": "rgba(180,180,0,1)", "%": "rgba(180,40,0,1)", }, },this.cbGridBoardClassic3DMargin,orthoBoardDelta); </code></p> <p>and a few lines below:</p> <p><code> boardLayout: [ ".#%.#%.#", "#%.#%.#%", "%.#%.#%.", ... </code></p>

📝Michel Gutierrez wrote on Fri, Apr 15, 2016 05:15 PM UTC:
<p>Giving it more thought, it should rather be:</p> <p><code> var orthoBoard3d = $.extend(true,{}, ,this.cbGridBoardClassic3DMargin,orthoBoardDelta,{ 'colorFill' : { ".": "rgba(204,40,0,1)", "#": "rgba(180,180,0,1)", "%": "rgba(180,40,0,1)", }}); </code> </p>

🕸Fergus Duniho wrote on Fri, Apr 15, 2016 06:53 PM UTC:
Neither assignment of orthoBoard3d changed the colors of the spaces. I initially modified your suggestions to use my choice of colors and to replace the % with a +, since I already modified some code to use the + sign based on code for Glinski's Hexagonal Chess. Since that didn't work, I copied them verbatim. Since that didn't work either, I commented out my changes to View.Game.cbGridBoardClassic and View.Game.cbGridBoardClassic2D and copied them verbatim again. It still didn't work. The spaces remained black and white.

📝Michel Gutierrez wrote on Fri, Apr 15, 2016 10:09 PM UTC:
<p>Fergus,</p> <p>I just sent you by mail a version of <code>cavalier-custom-view.js</code> that implements the 3 colors board. I tested it successfully.</p> <p>Maybe the problem you were having was related to the cache. Since embedding Jocly works with an iframe, cache may act weirdly, particularly on Firefox. Chrome might work better for those developments. Or relaunching Firefox also works.</p>

🕸Fergus Duniho wrote on Fri, Apr 15, 2016 11:10 PM UTC:
The cache had been giving me problems in Firefox, but I figured out that if I clear the cache and reload with a button that reloads a page without using the cache, I regularly get Jocly to use the latest version of my script. In fact, the two pieces of code you suggested had different effects, which I was able to notice because I have been clearing the cache. The first one simply failed to change the colors, while the second replaced the board with a large white square. I checked for your email but didn't see it. So I'll check again later.

📝Michel Gutierrez wrote on Fri, Apr 15, 2016 11:42 PM 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>

🕸Fergus Duniho wrote on Sat, Apr 16, 2016 01:46 AM 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 Sat, Apr 16, 2016 07:44 AM 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 Sat, Apr 16, 2016 01:46 PM 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 Sat, Apr 16, 2016 02:47 PM UTC:
In the view, just do something like <code>View.Game.cbTargetSelectColor = 0xff8800;</code>

🕸Fergus Duniho wrote on Mon, Apr 18, 2016 01:27 AM 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 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>

📝Michel Gutierrez wrote on Mon, Apr 18, 2016 01:57 PM 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>

Carlos Cetina wrote on Mon, Apr 18, 2016 05:40 PM 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 Mon, Apr 18, 2016 09:52 PM 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 Tue, Apr 19, 2016 12:33 AM UTC:
You are welcome. OK, don't worry, I understand. Hopefully such developers appear, arise, come up!

🕸Fergus Duniho wrote on Tue, Apr 19, 2016 03:57 PM 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="/play/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>

📝Michel Gutierrez wrote on Tue, Apr 19, 2016 04:35 PM 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 Wed, Apr 20, 2016 12:28 AM 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="/play/grandchess.html">Grand Chess</A> and <A HREF="/play/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 Wed, Apr 20, 2016 12:50 AM UTC:
Very good, thanks !

🕸Fergus Duniho wrote on Wed, Apr 20, 2016 01:09 AM 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.

jcfrog choain wrote on Wed, Apr 20, 2016 06:27 AM 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 Wed, Apr 20, 2016 05:15 PM 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 Thu, Apr 21, 2016 08:46 AM 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 Fri, Apr 22, 2016 04:30 PM UTC:
<P>Michel,</P> <P>I'm currently working on <A HREF="/play/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>

📝Michel Gutierrez wrote on Fri, Apr 22, 2016 05:16 PM 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 Fri, Apr 22, 2016 07:49 PM 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 Fri, Apr 22, 2016 11:34 PM 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>

📝Michel Gutierrez wrote on Tue, Apr 11, 2017 10:35 AM UTC:

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


🕸Fergus Duniho wrote on Tue, Apr 11, 2017 03:14 PM 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.


52 comments displayed

Earlier Reverse Order Later

Permalink to the exact comments currently displayed.