Home

Wrong Moves, Right Moves

Posted on 2008-07-12 23:55 JST by Curt Sampson :: comments enabled

I had a bad feeling when we decided to use hGetContents early in the day, and I shouldn’t have ignored it. We got nailed exactly as I did three months ago when first starting the trading system I’m writing in Haskell; it got way too lazy, and never actually executed enough code to generate any output until the connection it was reading from was closed by the remote end. When we started trying to send commands, we discovered that we happily sat there sucking data and doing nothing else.

Ouch.

So we did a bit of emergency surgery and are now doing a non-lazy read of each message, and passing it to the parser. That’s a story in itself, since we discovered a few issues in it that required a minor redesign. (Hint: don’t use Parsec’s “try” if you’ve got other choices.)

Chris showed up in the meantime, and he and Leon started working on some of the movement stuff, quickly putting together the “turn for home, and damn the torpedos” algorithm.

Well, between these, it all suddenly came together and we were, frankly, a bit surprised when we watched our little guy make the right moves head straight home (well, ok, weave home) in a simulator run. So we finally have something we can submit!

Add a comment »
comments are moderated