Java Port of GNU Chess

A week or two ago I started porting GNU Chess from C to Java in my spare time. The main motivation is to refresh my Java skills after two years of C++ immersion. It’s amazing how quickly you can lose the subtleties of a tool when you don’t use it.

I’m sure the project will succeed at making we aware of the Java/C differences, but I have to admit it’s unlikely the port will produce a runnable chess-plaing program even if I stick with it. GNU Chess code is pretty hairy, especially since it sacrifices clarity for speed. But if it does by chance run, it will serve as an interesting Java benchmark and will give me something to tinker with.

So far I’ve been translating each file to a Java class composed of static members, and I’m probably about 15% done by volume. The biggest headache so far has been lexpgn, which is a PGN (Portable Game Notation) file parser that is generated from a grammar description, sort of like ANTLR but different. I’ve barely used ANTLR, but if I knew it well, the thing to do would be to translate the lexpgn grammar to ANTLR syntax directly. The main lex() function is 800 lines long with nested switch statements and gotos …