display | more...

On HTML-based chess boards and a rant

The Institute where I work has recently revived its Chess club. Even though I'm not a good player by any measure, I'm in charge of making some sort of resource library for its members. With that goal in mind, I've been transcribing a few public domain chess books along with anthologies of the club's annotated games.

But I'm running into some problems. One problem. One that (I suspect) has plagued chess writers, librarians, archivists and amateurs of centuries past.

Getting the books is easy, thanks to Gutenberg Project, the Internet Archive and several other treasures of mankind. I've been able to procure a copy of José Raúl Capablanca's Chess Fundamentals that surely will serve its purpose here. Transcribing the games is easy as well. Our sanctioned games have to be transcribed down thrice: one copy per player and one for our official records.1

The problem is---as others have correctly pointed out---that following along with chess notation is difficult for beginners/amateurs like myself. That's one of the beauties of formats like PGN: it's possible to transmit chess moves that are both human-readable and machine-parseable, so one can choose to follow along with the movetext alone if you can do it, or have a machine create a semi-animated board of the game, step-by-step.

But alas, it's not so easy. One of the pillars of our library is to produce time-robust electronic materials that hopefully will be published on paper in the future. This means creating somewhat static content using as little external resources as possible. Or (in words of the Club's president) documents in as pure HTML as possible.

The good, I've seen this problem elsewhere (or should I say, I've seen it everywhere), and may be able to replicate the solution. I face similar restrictions here: no iframes, no embedded scripts, no user-defined CSS... It's possible to create chessboards using only <table> tags

The bad, it's incredibly time-consuming to get it right and readable.

For instance, there's this handy generator that takes a FEN position and outputs it as an HTML table. But it doesn't look good. For instance, the position

rn1qkbnr/pb3ppp/1p6/2pp4/3P1B2/2N2N2/PPP2PPP/R2QKB1R w KQkq - 0 7
is rendered like so:


Yeah, it's not pretty and it's not very readable. For starters, it would look better if the squares were properly colored2 It's also relatively small, I can't easily tell the white pieces apart. The first issue can be solved by cleverly replacing every second <td> tag with <th>. The second can be solved by wrapping every piece (and perhaps some non-breaking spaces) in several <big> tags.

But that doesn't solve the fundamental rant that gives birth to this daylog: the tools are there to be used! Now, E2 is almost exclusively text-based and it's foolish for me to expect it to support proper CSS classes or PGN rendering, that is not its purpose. But when you ask me to produce machine-commentated documents of 45 chess games and you expect them to be exclusively in HTML... well, it's madness. Lucas Chess can easily generate images from all board positions from a given game, extracting the comments can be done in a myriad of ways... heck, even with our shoestring budget I'm sure we could host a simple CSS file or script in our server for better game analysis. 

The (already small) promise of publishing these anthologies on dead trees should have no bearing on our record keeping. Even if we managed to get enough money for a small print, we have no physical space for all those books. Moreover, only a fraction of our members would even check out/buy them. No, let's use interactive media now that we have it. An anthology will take months to even prepare, a game can be imported and studied into suitable software in seconds. Let's focus on actually studying and discussing chess instead of turning ourselves into a failed vanity press.

1: I'm aware lots of management can be easily automated these days, but we have practically zero budget and our members are spread through 5 or so different internet chess platforms (lichess et al.), so unifying them is impractical. The best we've managed so far is to centralize all records in a somewhat agnostic database and have some volunteers mirror it to their respective platforms with the caveat that those are only mirrors and not the official records.

2: As in, alternating dark and light colors