AI Challenge - Ants
maarten van damme
maartenvd1994 at gmail.com
Tue Nov 8 12:04:23 PST 2011
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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20111108/f2c824c1/attachment.html>
More information about the Digitalmars-d-learn
mailing list