FENipulator

Thu 2012.01.05
by brian hefele

FENipulator is my latest project, a chess board application written in PHP. I call it a chess board application and not a chess application, because of its dumb nature. With a few small exceptions, it does not care about (or, frankly, know) the rules of chess. It does not, generally speaking, validate anything. It assumes the players are smart and honest enough to play by the rules. It also does not keep track of anything that isn’t a component of Forsyth-Edwards Notation(FEN). It is not connected to a database, it has no sense of state. Rather, it relies entirely on being passed FEN via HTTP-GET. It takes in FEN, allows the player to make a move, and generates new FEN based on the move made.

Let me back up a little bit, and say that as much as I love gaming, chess is almost certainly my favorite game. Correspondence chess systems online have all proven too heavy and complicated for my taste. I decided last night to implement an extremely simple system myself, a system that just simplified the process of getting the state of a chess board back and forth among two players. Play is simple — white clicks a piece to select it, clicks a space to move it to, reviews her move, and copies/pastes a link to the current board state to black. The link can be sent over email, IM, Twitter, whatever. Black does the same, and so on until the game is over. Because no state is ever saved on the server, there’s no overhead for an individual game. Thus, there’s no incentive (or, possibility even) for me to make games time out after so much inactivity, etc. It is, perhaps easiest to simply think of FENipulator as an interface to viewing and manipulating FEN data — hence the name.

Simplicity exists in many aspects of FENipulator. Aside from the aforementioned lack of a database, FENipulator also makes zero use of Javascript. There are no images, pieces are all represented by text. If one wanted, one could use images for pieces and spaces, as all of that is defined in CSS. Every space is a span, every piece is an :after pseudo-element attached to that span. For users who like their board flipped, a setting for this is possible using vendor-specific CSS transforms. Thus, flipping is not available on IE or older browsers, but for users of modern browsers, the possibility is there.

Update: Version 1.4 has all the short-term improvements taken care of except figuring out how I’m going to license the thing (see footnote). I got a bit carried away. Anyway, without going into the full changelog, here’s what has happened since v0.9: pawn promotion (to queen only); en passant (works on board and is recorded in FEN); POST is now used for sending move to/from data instead of GET, this meant switching the spaces from <a> to <button>; some classes added to CSS, making board-flipping easier and more things possible with board display (active state now exists after a move, showing to and from); board state URLs go through urlencode(), so everything validates now; and finally, no spaces are ‘live’ after a move has been made — the user must either choose to send the link or reset the board (the earlier behavior where the user could essentially change their move was unintentional and unpredictable). Anyway, read the footnote about licensing, then download it here, or just play.

As I have not yet determined how to license FENipulator, currently all rights are reserved. This will change soon, I promise. Also, know that while I have tested it, and it should not be able to cause any damage, I assume no liability or responsibility for its installation and/or use.