After a gap of three years, I attempted to do the task for ICFPC 2015. The task was to write a program that could play a game of (what was essentially) hexagonal Tetris with a few twists. There was a time-limit of 72 hours to finish this task in any programming language on almost any platform. As usual, by the end of the third day I was quite far from finishing it, but ended up having a little bit of fun.
My attempts at ICFPC each year now follow a distressingly-similar pattern:
- Resolve at the end of the previous year's contest to become comfortable enough with a high-level functional programming language like Haskell in time for this year's contest, so that I can do the task in that language.
- Far from having managed to do that, settle on using a relatively low-level programming language like C, C++ or Java, which causes me to waste time on mundane issues.
- Spend most the time creating a visualizer for the task, mostly in SDL, in order to “understand it better”before tackling it.
- Spend the remaining time re-factoring the code or debugging what turn out to be really silly issues.
- Realize it is too late to actually finish the original task within the time-limit. Promise to come back to the task after the actual contest in order to finish it at leisure.
- Never end up revisiting the task as I get distracted by other things in life.
Needless to say, this is not good; not good at all.
The visualizer turned out to be passable for manually playing through the games. (Thanks to Solarized, I had a decent color-palette to pick colors from - I think I'll adopt it for my other projects as well - I already use it in my editor and terminal.)
I had some trouble with the task-specification - in particular figuring out what exactly is a legal move for a Unit. I am still not sure I have it right as many games seem unplayable according to the rules. I had trouble getting my head wrapped around a hexagonal grid, especially for implementing the turning of Units - I cursed myself for not having consulted Amit Patel's excellent reference on hexagonal grids earlier, as his coordinate transforms make working with hexagonal grids relatively easy.
As usual, the source-code for my attempt (such as it was) can be found on Bitbucket, on GitHub and on GitLab.