My bot is getting better. After taking a little time off, I spent a few hours last night making updates. While I haven’t deployed them, my current bot has continued to test it’s potential. It’s been playing a lot of random_walk maps (which it handles better than the maze maps), and my rank is now in the top 1200.
Current intelligence level: stupid swarm.
While spending a bunch of time yesterday, I uncovered a couple of bugs in my code that explained some of the odd behavior I’ve seen (such as ants getting stuck together in small features). It turns out that I was using
contains on a
list, which does nothing. This is actually rather odd.
contains checks to see if a key is in a collection, but doesn’t raise an exception in this circumstance.
keys shows the behavior that I was expecting:
user=> (contains? (list 1 2 3 4) 3) false user=> (keys (list 1 2 3 4)) ClassCastException java.lang.Long cannot be cast to [...]
So because of this, some of the tests I had in my code were useless, essentially always returning
false. On top of that, I found another bug. I was checking to see if collections were empty like this:
(if (empty my-collection) [...]
That’s a mistake too.
empty is a new function in Clojure 1.3 which returns an empty version of the collection passed to it (so it will give you an empty set if you pass it a set). This also caused subtle bugs. The correct function was
empty?, but I wasn’t looking that closely at autocomplete.
With that fixed, my bot looks quite a bit better. The ants don’t get stuck and they spread out better on all maps, even though there isn’t any code specifically instructing them to do that. When testing, I noticed that this means it’s much easier to take my hills because there are fewer ants milling about now. I added some code to have everyone rush home when an enemy approaches, but I haven’t given it any real test yet. It looked like it might have kicked in during test game, but I was tired of working by then and decided to do the real testing later.
So as it is, I don’t want to post my updated version until I can test better. If I post what I have at this moment I’m pretty sure my rating will drop more than a few points. But I now know that my bot can handle over 600 ants without timing out. Before it almost never got above ~250 because the ants ended up blocking the hills.