ICFP was always for us a reason to learn a new programming language. The first time was OCaml, two weeks before we choose the language and do our homework, but nothing beat getting your hand dirty with a short deadline to learn.
This years we decided to use Haskell (our team was named LazyMonkeys).
I am already pretty decent at it but it was a first for Pierre. Who by the way did a pretty good job. It was funny to see him use OCaml idioms like
let ininstead of the favored
where, but I was never found of
wheretoo since it remove the ability to read the code top to bottom.
The contest was very interesting with unusually clear and short instructions, I did not even print them. You can read all about how you had to help a poor rover find his way home on Mars while avoiding the Martians here. It also had a nice range of possible progress from a simple steering solution to a more complex strategy.
At first we kind of doubted of our choice since we had to do real time analysis of a telemetry feed and I seriously consider switching to Erlang. But there is good threading support in Haskell so we stayed with it.
Our solution :
We have a very simple one based on fuzzy steering. With a thread managing the network, one for the motion planning and a last one for visualization.
We lost a lot of time on the network part. The task recommended to disable Nagle’s algorithm which was only possible with the more advanced Network.Socket. The issue that gave me a lot of grief was that on the OS X 10.5 when doing a
localhostthe first answer is a IPv6 address. Network.Socket does not seem to be able to manage IPv6 so it was difficult to debug the issue.
We used OpenGL for displaying our robot activities :
It was very helpful in detecting logical errors.
Summary, what we did wrong:
- Did not have a comprehensive test bed to be able to measure our progress. Would have been very useful at the end when we try to tune our parameters.
- Did not create a trigonometric/geometric module early enough
- Discover that Aquamacs new version is way cooler that Emacs.app and spending 2 hours updating my
What we did right:
- Create a SVN in advance
- Build the OpenGL display, the one offered by the server was good enough for the first day but when we added more complex comportment we need more visual info.
- Choose a robust solution
- Made good use of Haskell laziness