26 September 2008

One from the archives

Ten years ago I wrote a little java applet (yes, an applet. Imagine that!) that plays Reversi, aka Othello - as an exercise for a Game Theory course I was taking.

I dug it up, and amazingly it compiles, runs and even works!

You can play against my little Reversi here (and it's totally free).

The program is a fine example of alpha-beta game tree pruning, using an evaluation function which takes into account the positions of the stones as well as the mobility of each player.

I'm sure one could write a much more sophisticated Reversi player, but even with low lookahead (4) it crushes me.

Download and play with the source code too - I'm releasing it open-source (under GPL). Just don't judge me by it - it was ten years ago, ok? There are member variables with names starting with uppercase letters ... there are ... ugh ... comments ... and all sorts of other atrocities in there. OMG there was even a new String("foo"); in there. I got rid of those, but it was too much effort to clean it up entirely. I don't write like that any more. I would like to say I never did, but I wasn't born perfect either ...

2 comments:

  1. but is there tests ???
    At least unit test (I beleave it's difficult to write FIT tests for applets).
    :P

    ReplyDelete
  2. unit tests? in 1998? whazza?

    seriously though an applet is just an ordinary desktop java application running in an applet sandbox, so you would test it like you would test any awt/swing application. Rumour has it that uispec4j is the winner in this category.

    ReplyDelete