Skip to main content

Checkers Easter egg for Swing applications

Posted by kirillcool on October 22, 2006 at 10:45 PM PDT

The laf-widget project allows not only plugging additional "feel" part to the Swing apps (described in this article), but also allows planting Easter Eggs in Swing apps without any change to the app code. The Matrix rain adds a Matrix-inspired screensaver, while Trellis project adds a line of Tetris-inspired games. And today another one of my pet projects was revived.

The game of Checkers (or Draughts) is much simpler than Chess (although I'm Russian, i never got past the basic moves :) and is real fun to play (i remember i played it for hours when i was a kid). Now you can play it against the computer using the Checkers project. It can be launched as either a standalone application (main class is org.jvnet.lafwidget.checkers.Checkers) or as a laf-widget plugin. Simply drop the checkers.jar somewhere in the classpath, run your app under laf-widget compliant look-and-feel, press Ctrl+Alt+C in any frame and begin to play.

Note that this was written in 2001 for AWT and Java 1.1. The GUI code is a complete mess, and shouldn't be reused anywhere. The engine itself, however, is quite fine. It uses the alpha-beta pruning search to find the next best move for the computer. It actually is quite good (i never have beaten it on the hard level, but then it's only me) - enjoy. Here are some screenshots:

Related Topics >>