Check out Janggi (Korean Chess), our featured variant for December, 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

Jocly. An html-based web platform for playing 2-player abstract stategy games.[All Comments] [Add Comment or Rating]
H. G. Muller wrote on Sun, Dec 31, 2023 08:07 AM UTC in reply to H. G. Muller from Sat Dec 30 03:09 PM:

I extended the cbPiecesFromFEN function to also propose a description of the castlings. That means it basically returns a complete game definition, which could be directly returned by the cbDefine function describing the game.

This means the implementation of, say, Capablanca Chess can be reduced to

(function(){
    var geometry=Model.Game.cbBoardGeometryGrid(10,8);

    Model.Game.cbDefine=function(){
        return this.cbPiecesFromFEN(geometry, "rnabqkbmnr/pppppppppp/10/10/10/10/PPPPPPPPPP/RNABQKBMNR");
    }
})();

The description of this new feature is this:

The returned object might also contain a property 'castle', if a King
and Rooks were present in the FEN and on the same rank. The default
displacement of the King is calculated by subtracting 3 from the
board width, and dividing that by 2, rounding down. That makes 2 on
8-wide boards, 3 on 9- and 10-wide boards, etc. The distance of the
left Rook from the edge is subtracted from this, though.

As castlings are highly variable it is likely that this is not what
you need. Therefore the returned object also has a method

p.setCastling(kstep,partnerName)

which you can use to force the King step you want, and let it castle
with other pieces than the Rook. If the second argument is omitted
it will default to 'rook', though. When you don't want any castling
at all, you simply do not copy p.castle to the castle property
in the object your cbDefine function returns.