make clean

May 13, 2008

HoM : an experiment in Scala

Filed under: Uncategorized — harshadrj @ 7:35 pm
Tags: ,

I wrote a little game in scala; House of Mirrors. It is a logic game heavily inspired by Chromatron.

It was just a for-fun project and I also wanted to familiarize myself with scala with a real-world application.

My notes:

  • I first wrote the core of the game, with no interface at all. It was probably about 100 lines of Scala code. I found I could easily design and code on the go.
  • I built up all objects using a hierarchy of case classes and stuck to immutable data types.
  • Adding a GUI layer on top of the core was easy with the SQUIB library. I think the total code was about 400 lines of code.
  • However, when dealing with colored light beams I had to get my hands dirty with Swing, since I wanted to define my own Composite class. I found some missing functionality in AWT and had to use Double buffering while compositing. This is what to took most of my time, though it’s just 17 lines of code
  • The next part was saving and loading game files in XML format. Needless to say, this was a breeze to write in Scala. Total code was about 500 lines of code
  • After a lot of game features and minor GUI enhancements the code now stands at 1k loc

The biggest hurdle I faced when dealing with Scala was a lack of documentation for the standard APIs. The others being : instability of the compiler itself, changing APIs and some inconsistencies in the language. An example of the latter; “case North” is treated differently from “case north”! why? because capitalisation of identifiers is treated specially! Bad design choice I think; it’s too quirky.

Most of these problems should go away with time & love but some like the above quirkiness are potential hair-pullers.

December 1, 2007

Game programming

Filed under: Uncategorized — pharaoh @ 5:24 pm
Tags: , , , , ,

The field of Game programming (writing computer games) has been breeding ground for many innovative ideas, and is always pushing computer science into newer frontiers. And, I don’t mean just the graphics FX, but also the algorithms/data structures used inside the game.

Here is a random collection of links:

Pathfinding algorithms

Interesting description of path-finding algorithms. I wish they had taught algorithms like this back in college.

RealTimeBattle

The objective of this game is to program robots, which are then run inside a simulated environment, and they can compete and attack each other. The robots can be programmed in any language and only communicate via stdin/stdout. I have played with this game many years back, and has helped me understand many concepts in computer science, AI and fishing. Ok, the last one might be wrong.. but who knows 🙂

One thing that this game taught me is the concept of Actors, which seem to be getting a lot of attention these days (Erlang Actors/Scala Actors or this or this or this)

Playing chess with a bayesian spam filter

The author of dbacl, a spam filter based on bayesian models, writes an interesting story of getting dbacl to play chess!

In fact, this is the approach used in most chess playing programs, in the opening section of the game. The opening section is more challenging to deal with because the number of legal moves is very high, and the scores of both players are very likely to be equal (by most heuristic algorithms).

Create a free website or blog at WordPress.com.