I've done it five or six times and found it got a lot easier every time.lucasart wrote: To be honest, building from scratch all the board representation and move generation code was so painful. I'm happy it's behind me, and I don't want to go in there again, unless I really have a good reason to.
Of course, the last few times I was fairly happy with how things had turned out earlier and so I based the newer design on the old one. It'd take me longer if I had to do it all completely from scratch.
I have no idea hoe everyone else does it, but in Jazz I simply store a flag "castle move" in the move structure (it's only one bit afterall), and I then pull the rook move from a table based on the king's destination square. Jazz doesn't play Chess960, but I don't think I'd change anything if I wanted to support that (but I'm not really interested in doing that).I would like to implement Chess960 for the next version. I haven't really thought about it though. Currently my castling moves are encoded as "e1g1" (if you see what I mean), so I was thinking of just coding castling moves as KxR whether in Chess960 or normal chess. I guess it would not be too hard to implement like this ? Is it how everyone else does this ? Are there nasty traps to watch out for ?
Sjaak does support Chess960, but it also generates castle moves rather differently from Jazz. It has a set of 2x2x3 bitmasks (for 2 colours, king and queen side castling, and three test-masks). The test masks inidcate which squares to king and rook are on, which squares should be empty and which squares should not be attacked. It also has the king's destination squares stored in a table.
Implementing castling for FRC (or any variant) just requires initialisation of the castle masks, which is done at the start of a new game (based on the starting position and the known rules, like "king goes to g1" for white kingside castling).
The only caveat I can think of is that castling in some FRC positions could be a null-move as far as the king or the rook is concerned; it's also possible that the destination square for the king isn't empty initially (it may contain the rook). Those could be things to look out for (it'd be for Jazz, although it wasn't for Sjaak).
In case you feel like giving it a try some time, it's a lot of fun.As for other chess variants, I'm not that much interested and will probably never to do anything else than normal chess and chess 960.