Sunday, December 20, 2020

Progress of AntiChess

AntiChess is the first on the list of Java open source games I wanted to improve. It has been abandoned for a long time (since 2003) and it looks like a small enough game to get into the improvement of Java based games.

I took the CVS from 2003 and had previously converted it to Git already. It used Ant as build system but I could quickly upgrade it to use Gradle and with a JDK version 11 (from AdoptOpenJDK) I could easily run the game and after some adoption also the tests. That remarkable, fully working backwards compatibility of Java is always very nice to see.


The game and tests were 8.8k lines of code (LOC) initially and with using code analysis features from IntelliJ and some optimizations I could reduce that to 7.6k LOC without changing the game even a single bit (I hope at least). 10% reduction is a typical value at this stage. While I was at it, I also re-arranged the package structure, converted constants to enums, encapsuled public variables with getters and setters, improved names of variables and fixed common spelling errors (with project wide search and replace in IntelliJ this is quite easy).

Now the difficult part begins. I really have to understand the code to further optimize and improve it. One big thing is that the computer opponent seems to evaluate moves but does not perform a move in time. Additionally, the differentiating between a 2-player and a 4-player game could be done much better. There is only one inheritance (for pieces) and there definitely could be more Interfaces (for the evaluator, for the engine, for the player, ...). Moves should be immutable, I think, but they aren't and I want to find out what is currently holding them back from being immutable. It's currently not clear if AntiChess could also play normal chess. I want to find out.

The graphics is relying on Java Swing, which is a quite old framework and doesn't look so shiny. However, I will not change that, only nicely separate the user interface from the rest of the game. This is definitely something that will remain for somebody else.

And I published the updated version of the game under the GPL-3.0 license (was MIT). That is a more restrictive license, but I definitely like it more for end user applications.

No comments:

Post a Comment