- Created Thursday, March 20th 2014 @ 23:36:35
I am playing with my bot and it turns out that my response exceed the time limit and the server return Null.
The timeout set on server maybe 2000, (ms ?). However, I don't know how do they count this, because when I ran on my computer with the same setup, it takes less than 1 sec.
Besides, the go place_armies plus the attack/transfer are 4000 in total. If my computation does not separate these activities then is there any way to use the limit of 4000 and return both the results?
Thanks you guys for your comment!
DeveloperCreated Friday, March 21st 2014 @ 08:27:00
The game server imposes memory and CPU limits on each bot (750 MB RAM, 1 CPU thread), this could be why your bot runs fine on your computer while being too slow on the server.
Regarding your second question , it's not possible tot use the combined time for place_armies and attack/transfer to calculate and send both messages.
- Created Friday, March 21st 2014 @ 08:56:56
OMG, what is your algorithm if it takes 4s? I think you should try to optimize it
- Created Friday, March 21st 2014 @ 11:34:43
Of course it is possible to use both the two second times. That is, you can return army placement after two seconds and then attacking and transferring after two more seconds of calculations. You'll have to do the work yourself, though.
The idea is simple. You keep track of the time you spent on the first function. When getting close to two seconds, store your current state persistently and return the army placement. When being asked to do return the attacks and transfers, you continue the calculations and you need to be done with your calculations.
However, this isn't truly a solution to your problem. If your code is taking that long to execute, you're really doing something wrong. There's basically two options, and my money is on the first:
You're not really testing with the exact same input as when it goes wrong at the AIGames' machine. A such, there's an infinite loop or huge O-factor you haven't been taking into consideration yourself.
You still have a big O-factor and your algorithm really is too slow. However, on your own hardware you're able to keep each turn below a second just by having more juice than on the AIGames' server. One should always keep in mind that every computer is different, and you can't really compare "raw" run times of algorithm on different computer; an difference of a factor 2 or 4 isn't anything you shouldn't be expecting on reasonable hardware, on high end hardware you can get much faster compared to slow hardware. It should also be said that with the extreme simplicity of the map, there's really no good reason to take that long to do a single turn.
- Created Saturday, March 22nd 2014 @ 00:44:52
Hello.... from a Friday night....
Thank you very much guys for very comprehensive answers! I definitely have to check my code for computation time.
However, I think the way to separate and restrain the place armies and attack/transfer moves timeouts is not very flexible, because I believe that not only me but also other people do not separate these tasks. I often return the 2 moves at the same time after the computation.
- Created Saturday, March 22nd 2014 @ 00:57:51
The thing is, 2 seconds should be plenty to do both.
In other words, be happy that you get two times two seconds. They could easily say you only get two seconds total and it should still be way more than one should ever need.
- Updated Saturday, March 22nd 2014 @ 10:39:31
Happy - Pharrell Williams, lol =)