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
next sibling 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 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
prev sibling next sibling parent "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
prev sibling next sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
--00504502c305934d1704afd5e238
Content-Type: text/plain; charset=ISO-8859-1

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 :)

--00504502c305934d1704afd5e238
Content-Type: text/html; charset=ISO-8859-1

great, I&#39;m going to try it out.<div>I&#39;ve been looking for something fun
to do while improving programming skill for ages and this looks great :)</div>

--00504502c305934d1704afd5e238--
Oct 21 2011
prev sibling next sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
--00504502c305c6df1804afe5b624
Content-Type: text/plain; charset=ISO-8859-1

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);

--00504502c305c6df1804afe5b624
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I just downloaded the starter package and it gives to following errors:<div=
ants.d</div><div>-line 64: data.splitlines()=3D&gt;splitlines(data)</div><=

-line 104:=A0data.splitlines()=3D&gt;splitlines(data)</div> <div>-line 111:tokens[0].toLower=3D&gt;tolower(tokens[0])</div><div>-line 3= 13:currentline.tolowerInPlace()=3D&gt;tolowerInPlace(currentLine);</div> --00504502c305c6df1804afe5b624--
Oct 22 2011
prev sibling next sibling parent 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
prev sibling next sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
--001485f1bdc444b74c04aff80fcc
Content-Type: text/plain; charset=ISO-8859-1

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?

--001485f1bdc444b74c04aff80fcc
Content-Type: text/html; charset=ISO-8859-1

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

--001485f1bdc444b74c04aff80fcc--
Oct 23 2011
prev sibling next sibling parent 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?
 I&#39;m noticing some problems, there are some methods missing used in
 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
prev sibling next sibling parent "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?
 I&#39;m noticing some problems, there are some methods missing used in
 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
prev sibling next sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
--0016e6d7e688835c4604b13ead29
Content-Type: text/plain; charset=ISO-8859-1

I have stolen an isvisible method from the c# bot

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)

--0016e6d7e688835c4604b13ead29
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I have stolen an isvisible method from the c# bot<div><br></div><div><div>b=
ool isVisible(Loc loc){</div><div><span class=3D"Apple-tab-span" style=3D"w=
hite-space:pre">			</span></div><div><span class=3D"Apple-tab-span" style=
=3D"white-space:pre">			</span>Loc[] offsets;</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">			</span>int=
 squares =3D cast(int)floor(sqrt(_viewradius2));</div><div><span class=3D"A=
pple-tab-span" style=3D"white-space:pre">			</span>for (int r =3D -1 * squa=
res; r &lt;=3D squares; ++r){</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">				</span>fo=
r (int c =3D -1 * squares; c &lt;=3D squares; ++c){</div><div><span class=
=3D"Apple-tab-span" style=3D"white-space:pre">					</span>int square =3D r =
* r + c * c;</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">					</span>i=
f (square &lt; _viewradius2){</div><div><span class=3D"Apple-tab-span" styl=
e=3D"white-space:pre">						</span>Loc newLoc =3D {r,c};</div><div><span cl=
ass=3D"Apple-tab-span" style=3D"white-space:pre">						</span>offsets~=3Dne=
wLoc;</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">					</span>}=
</div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre">				</s=
pan>}</div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre">		=
	</span>}</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">			</span>for=
each (ant;_myAnts)</div><div><span class=3D"Apple-tab-span" style=3D"white-=
space:pre">			</span>{</div><div><span class=3D"Apple-tab-span" style=3D"wh=
ite-space:pre">				</span>foreach (offset;offsets)</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">				</span>{<=
/div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre">					</s=
pan>if ((ant.col + offset.col) =3D=3D loc.col &amp;&amp;</div><div><span cl=
ass=3D"Apple-tab-span" style=3D"white-space:pre">						</span>(ant.row + of=
fset.row) =3D=3D loc.row)</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">					</span>{=
</div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre">							=
	</span> return true;</div><div><span class=3D"Apple-tab-span" style=3D"whi=
te-space:pre">					</span>}</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">				</span>}<=
/div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre">			</spa=
n>}</div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre">			<=
/span>return false;</div>
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre">			</span></d=
iv><div><span class=3D"Apple-tab-span" style=3D"white-space:pre">		</span><=
/div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre">		</span=
}</div>

of shortcommings, the hell it is to debug that thing and when it finally c= ompiles fine on 2 machines it gives a cryptic error about glue.c (that had = something to do with rdmd)</div> --0016e6d7e688835c4604b13ead29--
Nov 08 2011
prev sibling next sibling parent "Marco Leise" <Marco.Leise gmx.de> writes:
Am 08.11.2011, 21:04 Uhr, schrieb maarten van damme  
<maartenvd1994 gmail.com>:

 I have stolen an isvisible method from the c# bot

 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 next sibling parent maarten van damme <maartenvd1994 gmail.com> writes:
--0016e6dee9644aa26804b150f2c3
Content-Type: text/plain; charset=ISO-8859-1

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

--0016e6dee9644aa26804b150f2c3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <pre class=3D"error" style=3D"margin-top: 0px; padding-top: 5px; padding-ri= ght: 5px; padding-bottom: 5px; padding-left: 5px; border-top-width: 1px; bo= rder-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; bo= rder-style: initial; border-color: initial; font-size: 12px; font: inherit;= vertical-align: baseline; font-family: Consolas, Inconsolata, monospace; b= order-top-style: dashed; border-right-style: dashed; border-bottom-style: d= ashed; border-left-style: dashed; border-top-color: rgb(139, 0, 0); border-= right-color: rgb(139, 0, 0); border-bottom-color: rgb(139, 0, 0); border-le= ft-color: rgb(139, 0, 0); background-image: initial; background-attachment:= initial; background-origin: initial; background-clip: initial; background-= color: rgb(255, 255, 255); overflow-x: auto; overflow-y: auto; text-align: = left; width: 680px; line-height: 18px; "> dmd: glue.c:719: virtual void FuncDeclaration::toObjFile(int): Assertion `!= vthis-&gt;csym&#39; failed.</pre>Not able to reduce the code that causes it= as it compiles fine here and it takes 10 minutes to upload new code and le= t it compile/play.<div> <br><div class=3D"gmail_quote">2011/11/8 bearophile <span dir=3D"ltr">&lt;<= a href=3D"mailto:bearophileHUGS lycos.com">bearophileHUGS lycos.com</a>&gt;= </span><br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bor= der-left:1px #ccc solid;padding-left:1ex;"> maarten van damme:<br> <div class=3D"im"><br> &gt; But I have also lost interest because of a couple of shortcommings, th= e<br> &gt; hell it is to debug that thing and when it finally compiles fine on 2<= br> &gt; machines it gives a cryptic error about glue.c (that had something to = do<br> &gt; with rdmd)<br> <br> </div>What is the message of this cryptic error, and are you able to reduce= the code that causes it?<br> <br> Bye,<br> <span class=3D"HOEnZb"><font color=3D"#888888">bearophile<br> </font></span></blockquote></div><br></div> --0016e6dee9644aa26804b150f2c3--
Nov 09 2011
prev sibling next sibling parent "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,  

 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  

 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
prev sibling parent "Marco Leise" <Marco.Leise gmx.de> writes:
Looks like issue #6395 or any of the issues linked in there:  
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