Last Sunday, after getting bored implementing error handling in the Ruby version of the food journal, I decided to take a stab at the ICFP 2009 Programming Contest. Although already finished, the problem is so intense and interesting that I had to try. My solution is written in the lovely functional language Haskell.

Today, I achieved a milestone. My program can load and execute the Orbit virtual machine, run a sequence of frames and reports a score of -1.0 when the controlled satellite’s fuel is exhausted.

Browse the code on GitHub. Remember, I’m still learning, so don’t expect anything miraculous!

Memory Madness

19-Jul-2009 @ 16:00 I spent a couple of hours today analysing the performance of the VM implementation. Mostly because it was consuming all memory when running. I used the built-in profiling tools of GHC to find out where it was all going. Turns out that switching to unboxed arrays had a dramatic effect and exposed a bug in the code. Now the VM can run tens of thousands of frames with stable memory consumption. Pretty quick too when compiled with optimisation.

For those wanting to compile and run the code themselves, first install the Haskell Platform. Then cabal update; cabal install data-binary-ieee754 to get a necessary library. After cloning the Git repo, change to the src directory and make the VM executrable using ghc --make VM -main-is VM.main.

Leave a Reply

You must be logged in to post a comment.