www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - AI Challenge - Ants

reply "Marco Leise" <Marco.Leise gmx.de> writes:
Hi! I've been part of the team behind http://aichallenge.org/. We just  
started our next challenge about 30 minutes ago.
This will be the first time that DMD 2.054 is supported there and since  
I've been posting on this NG a few times I though it would be a good place  
to make an announcement.

So here is the deal: You write a program that controls a population of  
ants. You get a number of ant hills and explore the map with your ant  
horde looking for food to produce more ants and enemy ant hills that you  
can raze for points.
There is fog-of-war and obstacles. Moving ants in groups gives them better  
chances to survive by outnumbering enemies. The map is on a grid and ants  
wrap around if they move over the edges. A match usually has between 2-8  
players and is turn based. The players make their moves simultaneously  
within a time window of 500ms. Oh yeah and it is free to sign up and  
requires no previous knowledge in AI programming.

Feel free to ask questions on the IRC channel #aichallenge on Freenode.

- Marco
Oct 20 2011
parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Friday, October 21, 2011 06:22:43 Marco Leise wrote:
 Hi! I've been part of the team behind http://aichallenge.org/. We just
 started our next challenge about 30 minutes ago.
 This will be the first time that DMD 2.054 is supported there and since
 I've been posting on this NG a few times I though it would be a good place
 to make an announcement.
 
 So here is the deal: You write a program that controls a population of
 ants. You get a number of ant hills and explore the map with your ant
 horde looking for food to produce more ants and enemy ant hills that you
 can raze for points.
 There is fog-of-war and obstacles. Moving ants in groups gives them better
 chances to survive by outnumbering enemies. The map is on a grid and ants
 wrap around if they move over the edges. A match usually has between 2-8
 players and is turn based. The players make their moves simultaneously
 within a time window of 500ms. Oh yeah and it is free to sign up and
 requires no previous knowledge in AI programming.
 
 Feel free to ask questions on the IRC channel #aichallenge on Freenode.
Sounds cool, but there's actually a list specifically for announcements: digitalmars-d-announce. http://www.digitalmars.com/NewsGroup.html - Jonathan M Davis
Oct 20 2011
parent reply "Marco Leise" <Marco.Leise gmx.de> writes:
Am 21.10.2011, 06:31 Uhr, schrieb Jonathan M Davis <jmdavisProg gmx.com>:

 On Friday, October 21, 2011 06:22:43 Marco Leise wrote:
 Hi! I've been part of the team behind http://aichallenge.org/. We just
 started our next challenge about 30 minutes ago.
 This will be the first time that DMD 2.054 is supported there and since
 I've been posting on this NG a few times I though it would be a good  
 place
 to make an announcement.

 So here is the deal: You write a program that controls a population of
 ants. You get a number of ant hills and explore the map with your ant
 horde looking for food to produce more ants and enemy ant hills that you
 can raze for points.
 There is fog-of-war and obstacles. Moving ants in groups gives them  
 better
 chances to survive by outnumbering enemies. The map is on a grid and  
 ants
 wrap around if they move over the edges. A match usually has between 2-8
 players and is turn based. The players make their moves simultaneously
 within a time window of 500ms. Oh yeah and it is free to sign up and
 requires no previous knowledge in AI programming.

 Feel free to ask questions on the IRC channel #aichallenge on Freenode.
Sounds cool, but there's actually a list specifically for announcements: digitalmars-d-announce. http://www.digitalmars.com/NewsGroup.html - Jonathan M Davis
Thanks for mentioning it.
Oct 21 2011
next sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
great, I'm going to try it out.
I've been looking for something fun to do while improving programming skill
for ages and this looks great :)
Oct 21 2011
prev sibling parent reply maarten van damme <maartenvd1994 gmail.com> writes:
I just downloaded the starter package and it gives to following errors:
ants.d
-line 64: data.splitlines()=>splitlines(data)
-line 65:line.strip().toLower()=>line.strip().toLower()
-line 104: data.splitlines()=>splitlines(data)
-line 111:tokens[0].toLower=>tolower(tokens[0])
-line 313:currentline.tolowerInPlace()=>tolowerInPlace(currentLine);
Oct 22 2011
parent reply Jesse Phillips <jessekphillips+d gmail.com> writes:
I downloaded the starter pack last night and everything compiled. 2.055 
and 2.054

On Sat, 22 Oct 2011 18:30:55 +0200, maarten van damme wrote:

 I just downloaded the starter package and it gives to following errors:
 ants.d -line 64: data.splitlines()=>splitlines(data)
 -line 65:line.strip().toLower()=>line.strip().toLower()
 -line 104: data.splitlines()=>splitlines(data)
 -line 111:tokens[0].toLower=>tolower(tokens[0])
 -line 313:currentline.tolowerInPlace()=>tolowerInPlace(currentLine);
 I just downloaded the starter package and it gives to following
 errors:<div>ants.d</div><div>-line 64:
 data.splitlines()=&gt;splitlines(data)</div><div>-line
 65:line.strip().toLower()=&gt;line.strip().toLower()</div><div>-line
 104: data.splitlines()=&gt;splitlines(data)</div>
 
 <div>-line 111:tokens[0].toLower=&gt;tolower(tokens[0])</div><div>-line
 313:currentline.tolowerInPlace()=&gt;tolowerInPlace(currentLine);</div>
Oct 22 2011
parent reply maarten van damme <maartenvd1994 gmail.com> writes:
I'm noticing some problems, there are some methods missing used in the
tutorial like "unocupied", the do_setup part and the visible method. Is this
package complete or am I missing something?
Oct 23 2011
parent reply Jesse Phillips <jessekphillips+d gmail.com> writes:
On Sun, 23 Oct 2011 16:24:09 +0200, maarten van damme wrote:

 I'm noticing some problems, there are some methods missing used in the
 tutorial like "unocupied", the do_setup part and the visible method. Is
 this package complete or am I missing something?

 the tutorial like &quot;unocupied&quot;, the do_setup part and the
 visible method. Is this package complete or am I missing something?
It doesn't appear to perfectly match the tutorial. I'm not sure if the tutorial is intended to have you write in the details (didn't check if the Java version provided them). But that is what I did anyway. The one issue I've run into is trying to use the seed, details in the Random, not so random? post.
Oct 23 2011
parent reply "Marco Leise" <Marco.Leise gmx.de> writes:
Am 23.10.2011, 19:52 Uhr, schrieb Jesse Phillips  
<jessekphillips+d gmail.com>:

 On Sun, 23 Oct 2011 16:24:09 +0200, maarten van damme wrote:

 I'm noticing some problems, there are some methods missing used in the
 tutorial like "unocupied", the do_setup part and the visible method. Is
 this package complete or am I missing something?

 the tutorial like &quot;unocupied&quot;, the do_setup part and the
 visible method. Is this package complete or am I missing something?
It doesn't appear to perfectly match the tutorial. I'm not sure if the tutorial is intended to have you write in the details (didn't check if the Java version provided them). But that is what I did anyway. The one issue I've run into is trying to use the seed, details in the Random, not so random? post.
Sorry for not checking back here. When I wrote the D starter bot, the tutorial didn't exist yet and I didn't do anything with it later on except keeping it up to date with the game specs. If the Java/Python bots have this functionality it should have been added and I believe that other starter bots miss it as well. It is a bit of a mixed blessing though, because it doesn't define if a square changes its 'occupied' state when you issue an order for an ant to move onto it. The visible() function sounds nice to have though :p. It is needed to distinguish between items that went out-of-sight and those that were collected/destroyed in any case. Funnily, after writing the visualizer, the D and Pascal starter bots and advertising the contest a bit I don't feel like participating in it any more. :)
Nov 08 2011
parent reply maarten van damme <maartenvd1994 gmail.com> writes:


bool isVisible(Loc loc){
 Loc[] offsets;
int squares = cast(int)floor(sqrt(_viewradius2));
for (int r = -1 * squares; r <= squares; ++r){
for (int c = -1 * squares; c <= squares; ++c){
int square = r * r + c * c;
if (square < _viewradius2){
Loc newLoc = {r,c};
offsets~=newLoc;
}
}
}
foreach (ant;_myAnts)
{
foreach (offset;offsets)
{
if ((ant.col + offset.col) == loc.col &&
(ant.row + offset.row) == loc.row)
{
 return true;
}
}
}
return false;
 }

But I have also lost interest because of a couple of shortcommings, the
hell it is to debug that thing and when it finally compiles fine on 2
machines it gives a cryptic error about glue.c (that had something to do
with rdmd)
Nov 08 2011
next sibling parent "Marco Leise" <Marco.Leise gmx.de> writes:
Am 08.11.2011, 21:04 Uhr, schrieb maarten van damme  
<maartenvd1994 gmail.com>:



 bool isVisible(Loc loc){
  Loc[] offsets;
 int squares = cast(int)floor(sqrt(_viewradius2));
 for (int r = -1 * squares; r <= squares; ++r){
 for (int c = -1 * squares; c <= squares; ++c){
 int square = r * r + c * c;
 if (square < _viewradius2){
 Loc newLoc = {r,c};
 offsets~=newLoc;
 }
 }
 }
 foreach (ant;_myAnts)
 {
 foreach (offset;offsets)
 {
 if ((ant.col + offset.col) == loc.col &&
 (ant.row + offset.row) == loc.row)
 {
  return true;
 }
 }
 }
 return false;
  }
Nice theft, although 'offsets' should really be a field of the Ants class and not recomputed on every invocation.
 But I have also lost interest because of a couple of shortcommings, the
 hell it is to debug that thing and when it finally compiles fine on 2
 machines it gives a cryptic error about glue.c (that had something to do
 with rdmd)
I tend to use a 'general purpose' Makefile for building, that I symlink into new projects and wait for a bigger, better build tool. Then I use the 'debug' target as the build command in DDT (Eclipse) and have an 'External Launcher' that runs gdb with the executable. The flags look like this: -w -unittest -debug -gc -L--export-dynamic. Still I mostly use writeln for debugging algorithms and in/out contracts to avoid bugs that are easy to catch there. As for the Ants game, you can add a flag to the engine, I think it was -I, that has it save bot input in a text file. If you feed that to your bot via stdin, the bot will behave exactly as during the game, but this time you can wrap it in a call to gdb, use a special debug build or add flags to your bot that enables more debugging output.
Nov 08 2011
prev sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
maarten van damme:

 But I have also lost interest because of a couple of shortcommings, the
 hell it is to debug that thing and when it finally compiles fine on 2
 machines it gives a cryptic error about glue.c (that had something to do
 with rdmd)
What is the message of this cryptic error, and are you able to reduce the code that causes it? Bye, bearophile
Nov 08 2011
parent reply maarten van damme <maartenvd1994 gmail.com> writes:
dmd: glue.c:719: virtual void FuncDeclaration::toObjFile(int):
Assertion `!vthis->csym' failed.

Not able to reduce the code that causes it as it compiles fine here and it
takes 10 minutes to upload new code and let it compile/play.

2011/11/8 bearophile <bearophileHUGS lycos.com>

 maarten van damme:

 But I have also lost interest because of a couple of shortcommings, the
 hell it is to debug that thing and when it finally compiles fine on 2
 machines it gives a cryptic error about glue.c (that had something to do
 with rdmd)
What is the message of this cryptic error, and are you able to reduce the code that causes it? Bye, bearophile
Nov 09 2011
parent reply "Marco Leise" <Marco.Leise gmx.de> writes:
Am 09.11.2011, 18:52 Uhr, schrieb maarten van damme  
<maartenvd1994 gmail.com>:

 dmd: glue.c:719: virtual void FuncDeclaration::toObjFile(int):
 Assertion `!vthis->csym' failed.

 Not able to reduce the code that causes it as it compiles fine here and  
 it
 takes 10 minutes to upload new code and let it compile/play.

 2011/11/8 bearophile <bearophileHUGS lycos.com>

 maarten van damme:

 But I have also lost interest because of a couple of shortcommings,  
the
 hell it is to debug that thing and when it finally compiles fine on 2
 machines it gives a cryptic error about glue.c (that had something to  
do
 with rdmd)
What is the message of this cryptic error, and are you able to reduce the code that causes it? Bye, bearophile
Try compiling all *.d source files at once with DMD 2.054 (x86_64) and -O -inline -release -noboundscheck, instead of using rdmd. That is basically what the server does. You may have triggered an unresolved and strange compiler bug unless this wouldn't happen with 2.056.
Nov 09 2011
parent "Marco Leise" <Marco.Leise gmx.de> writes:

http://d.puremagic.com/issues/show_bug.cgi?id=6395
It could actually depend on the order the source files are found and  
appended to the command line by the server's compile script. :-/
Nov 09 2011