Halite Home

Timing Out Frequently


#1

Hi all,

I've just discovered this game and it's been pretty awesome thinking about it. However I run into a problem of timing out. I've noticed that even the OverkillBot in the tutorial times out on my machine. I notice I get timeouts on the bot I submitted for competition about once in every five competitions, and these timeouts happen on 35x35, 40x40, 45x45, and 50x50 boards, even though I tried coding in some safeguards against timeouts. These constitute more than half of my losses, and it's really frustrating looking at replays where my bot seems to dominate up until the point it times out. How are you guys preventing your bots from timing out?

Thanks.


#2

From my experience even an N^2 algorithm is going to be absolutely fine and finish well under the 1s time limit.

Some may not have formal computer science backgrounds so I will just describe N^2 quickly. In this context that might be where you look at every single cell (lets say there are N cells) on the grid and for each cell you check all N cells on the grid against that cell for something like distance between this cell and every other cell or production difference or whatever it is you want to do.

I am using javascript and N^2 algorithms all over the place and it's still easily done in under the 1s.

Things that will probably make it take more than 1s
- Logging a lot of things to file
- N^3 algorithms

The simplest advice to give is, if you have 3 loops nested inside of each other, you may have gone too far... if there are just 2 loops inside of each other you should be fine. This is not a blanket rule.


#3

I see you're using Python ... did you try this?


#4

I'll give that a look. Right now I'm using stopit to try to prevent timeouts.


#5

@andrewyang96 Definitely use the alternative python package. It will give your code a 10/20x speed up.