It is currently Fri May 24, 2013 4:19 am Advanced search

Ants is over!

Code won't compile? Found a bug? Post here!

Re: Ants is over!

Postby zarkon » Tue Dec 20, 2011 5:35 am

zaphod wrote:Apart from the AI concepts, I also learnt that slower (interpreted) languages should be used only in the first 2 weeks for experimentation. If you stick to them because of ease of development, you might end up regretting later when speed matters!


:-) This looks like an opportunity to promote Common Lisp!

I used it at various stages of the competition as a scripting language, then used the profiler to identify what can be optimized. And optimizations paid off - (adding some type declarations and requesting speed optimizations from the compiler, along with reducing memory allocation) sped up some of the important parts by approximately two orders of magnitude.

Being a CL newbie (one of the points of using it in the contest was to learn more), I didn't even find some obvious spots where I could have gained some more 10x speed-ups (these are parts not already sped up by the aforementioned optimizations, so the last sentence doesn't imply 1000x speedups).

Having a good and easy to use profiler and an easy way to look at the assembly code generated for individual functions makes it easy to squeeze performance.

/Common Lisp promotion over.

I guess some higher level low level languages such as Java, C# and Go permit similar initial exploration followed by code tightening. I have yet to try Python and PyPy.

And, of course, algorithms matter a lot.

One question for the organizers: the official servers have 32 bit or 64 bit operating systems? SBCL obviously uses more memory on 64 bit, but having 16 registers, pentium 2 instructions (like conditional moves) and MMX/SSE must help a little with speed.
zarkon
Lieutenant
 
Posts: 10
Joined: Sun Dec 11, 2011 1:34 pm

Re: Ants is over!

Postby amstan » Tue Dec 20, 2011 5:40 am

zarkon wrote:One question for the organizers: the official servers have 32 bit or 64 bit operating systems? SBCL obviously uses more memory on 64 bit, but having 16 registers, pentium 2 instructions (like conditional moves) and MMX/SSE must help a little with speed.

64 bit.
Alexandru M. Stan
Contest Organizer
User avatar
amstan
Contest Organizer
 
Posts: 692
Joined: Sun Jan 31, 2010 4:02 am
Location: Stoney Creek, Ontario

Re: Ants is over!

Postby tiberiu44 » Tue Dec 20, 2011 9:02 am

Hello,
I noticed that all bots timeout since the contest started. My bot is written in C# but the timeout happens regardless of the programming language. I do have a timeout check, and also on my computer (which is a Asus n61j laptop) it takes about 100ms for 300 ants (worst case).
I don't see why this is happening, with the timeout check installed in multiple parts of the code and also i would like to mention that the first versions of the bot didn't even have timeout checks and they worked perfectly. I lost a couple of games because of this and they where against some lame bots. In this game seems like everyone timed out: http://aichallenge.org/visualizer.php?game=282998&user=4321


Also I wanted to know if it counts that I've been fighting an aggressive bot the whole game and I was winning in the end, but we reached the turn limit and he already razed a couple of enemy hills that belong to other bots who did not have any skill?
http://aichallenge.org/visualizer.php?game=279745&user=4321
If the contest does not run for a couple of weeks such situations will have a negative impact on the score (some bots just get lucky).

So, do be concise:
1) Why do the timeouts occur?
2) How long will the contest run?

Thank you!
tiberiu44
Cadet
 
Posts: 3
Joined: Tue Dec 20, 2011 8:38 am

Re: Ants is over!

Postby Frantic » Tue Dec 20, 2011 10:16 am

asmodeus wrote:Just out of interest, did you need to do any specific clever stuff to get the Ruby bot working decently? I started a last minute bot (15th December) and thought I'd probably get further quicker in Ruby than in C. It worked pretty well on my own PC, but timed out every game on the challenge servers - my timeout code just flat out didn't work once uploaded, and I never figured out a reason.


Yes, definitely. I would say the bulk of my time went into devising clever stuff to get some decent game performance. I ran into the timeout problems as well, which got me thinking about the so-called "clever stuff".

The most important, specifically related to ruby:

1) Cache everything that could possibly be reused, so that the references are held. This way, the garbage collection has less to do and will run in less time. As a side-effect, you get a performance boost because certain calculations have already been done (note the priority :-) overcoming the GC was more important than performance).

2) Check the time limit frequently; if a threshold value is passed, drop everythingn and send the 'go'. Ruby's throw-catch construct is your friend here. The calculations are prioritzed so that critical stuff is done first. If you reach the threshold, at least you have done something.

4) Perform long-running calculations using Fibers, so that they can be lifted over the turn interval. I started out with Threads, until I read the game rules.....

It hurt me that ruby bots never reached high rankings in the testing rounds (268th was the highest for any ruby bot I've seen). I guess that for the average person that would be a signal to change languages; I saw it as a challenge.

Hey, thanks for your interest, I appreciate that. Cheers,

Frantic.
Frantic
Major
 
Posts: 34
Joined: Fri Sep 02, 2011 3:11 pm

Re: Trophies for the winners

Postby itzkow » Tue Dec 20, 2011 12:07 pm

BenJackson wrote:I have a laser cutter and I was thinking of making trophies for the winners. This is my basic design idea:
award.png

Laser cut from 1/4" acrylic with engraving (the light color) and through-cuts for the "place" (the white). The bottom would be a 1/4" acrylic base (shown here edge-on). I picked orange due to the default first bot color but it could be clear or anything, really.

I could also add a line of engraving with the vital stats of the bot, and maybe make the whole thing bigger and with a multi-layer base for the first few places.

I'd provide these to anyone in the top 10 plus selected participants the community thinks made a special contribution, like those running TCP servers. For others I could sell them on request and donate the profits back to the challenge (if that's ever sorted). Unless all 8000 people want them and then we might need some alternate arrangement (get them mass produced without place numbers which I could add).


even though im probably not gonna be top ten and I understood like 50% of what you said
that sounds AWSOME and would be much appretiated!
itzkow
Cadet
 
Posts: 7
Joined: Wed Dec 14, 2011 8:27 pm

Re: Ants is over!

Postby KhipuKamayuq » Tue Dec 20, 2011 3:44 pm

tiberiu44 wrote:So, do be concise:
1) Why do the timeouts occur?

This might also be caused due to the new maps and new bot you are playing against.
Have you replayed the matches on you PC with a profiler attached? Sometimes the code is hitting a very rare cornercase that is beeing lifted due to the new environment. Astar and Quicksort are candidates that pop into my mind. My code does not use any timeout-checks what-so-ever. And as far as I know of (and worked towards) the maximum time complexity of my code lies arround O(n) therefore I just tweaked the code a point that might fit into a large Server-CPU Cache (3-6MB code+data) (Haskell memory profiling is so cute) and rewrote all code that does not meet my worst case time-complexity expectations of O(n).
And all this by using a langauage that was totaly new for me (Haskell) with lazyness and quite ugly thrunk-functions pilling up.
KhipuKamayuq
Lieutenant
 
Posts: 14
Joined: Tue Dec 20, 2011 12:19 am

Re: Ants is over!

Postby asmodeus » Tue Dec 20, 2011 5:12 pm

2) Check the time limit frequently; if a threshold value is passed, drop everythingn and send the 'go'.


I was setting a next_order variable on the ant objects, and had wrapped almost all the turn code inside a Timeout::timeout call, which should have triggered it to send the next_order for each ant. Worked OK on my machine, but not on the challenge servers...

I'm a C programmer by trade (generally stuff that has near real-time constraints), and recently been messing about with some Ruby stuff for web interfaces. Love the language, and the fact I can write an A* algorithm in 30 minutes and barely 30 lines of code, but on speed it is the polar opposite of C. Wish I'd had a bit more time to look into how to optimise some of this stuff :)

My bot is currently the lowest ranked Ruby bot! Although until the timeout problem hits, it is usually doing pretty well :)
asmodeus
Cadet
 
Posts: 6
Joined: Sun Dec 18, 2011 1:09 pm

Re: Trophies for the winners

Postby stilkin » Tue Dec 20, 2011 6:44 pm

BenJackson wrote:I have a laser cutter and I was thinking of making trophies for the winners.
I'd provide these to anyone in the top 10 plus selected participants the community thinks made a special contribution, like those running TCP servers.


That would be very nice!
Has anything yet been said by the organization itself about prizes?
User avatar
stilkin
Cadet
 
Posts: 4
Joined: Mon Nov 21, 2011 9:05 am

Re: Ants is over!

Postby Frantic » Tue Dec 20, 2011 6:57 pm

asmodeus wrote:
Love the language, and the fact I can write an A* algorithm in 30 minutes and barely 30 lines of code, but on speed it is the polar opposite of C. Wish I'd had a bit more time to look into how to optimise some of this stuff :)

My bot is currently the lowest ranked Ruby bot! Although until the timeout problem hits, it is usually doing pretty well :)


Yeah, ruby is great for a lot of stuff and I too fell in love with the expressiveness and clean and terse syntax (going back to java is a nightmare!). Unfortunately, for all the good things I have to say about it, it totally sucks at realtime applications. For proof, see the AI Challenge. QED.

Frantic was #1 in the ruby list for a short while; now some glaring bugs are emerging and the hapless bot is demonstrating decidedly brain-damaged behaviour. Serves me right for wanting to include some killer-features at the very last moment. I'll have a good cry about it this evening and then life goes on. I hope.

Frantic.
Frantic
Major
 
Posts: 34
Joined: Fri Sep 02, 2011 3:11 pm

Re: Ants is over!

Postby gnu264 » Tue Dec 20, 2011 7:42 pm

While random timeouts did occur during the training phase, they have much more serious effects now: each bot gets to play so preciously few games that even one game lost due to a timeout may have a huge impact on your final ranking! For example, my bot had only 6 games (while, on a side note, other bots had already managed to play 15+ games). During the 7th game, both me and my competitor timed out during the same turn: http://aichallenge.org/visualizer.php?g ... &user=8532

Would it be possible to introduce a rule like "if two or more bots time out within X turns of each other, the results of the game are disregarded and there is an immediate rematch"?
gnu264
Captain
 
Posts: 23
Joined: Tue Nov 08, 2011 5:27 pm

PreviousNext

Return to Technical Issues

Who is online

Users browsing this forum: No registered users and 1 guest

cron