Winner David (Rogue Ant 4)

2008-11-12 12:00:00 UTC

# Unplanned Darkness 10

Status: Passed
Results: 8149.05 (cyc: 14, node: 634)
CPU Time: 65.0379
Score: 8161.33
Submitted at: 2008-11-08 01:56:22 UTC
Scored at: 2008-11-08 01:57:52 UTC

Current Rank: 95th
Basis for: YSUD10 (diff)

Alan Chalker
08 Nov 2008
Lets see how this works
Code
```function [dRow,dCol,action,mark] = solver(mainMap,foodMap,myAntMap,opAntMap, ...
myScentMap,opScentMap,myDeathMap,opDeathMap)

K = [7 7 7 9 9  9 17 17 17 19 19 19 8 12 14 18];
L = [1 2 6 4 5 10 16 21 22 20 24 25 3 11 15 23];

% decide scent
Y = [7 8 9 12 13 14 17 18 19];
myScent = myScentMap(13);
H = mainMap == 1;
if H(13)
mark = 100;
else
mark = floor((max(myScentMap(Y))-myScent-1)/myAntMap(13));
end
myScentMap(H) = inf;

% fight if challenged
if (any(opAntMap(Y)))
action = -1;
dRow = 0;
dCol = 0;
if (sum(myAntMap(:))<8)||(rand < 0.5)

return
else
[r,c] = find(opAntMap(2:4,2:4)&~opAntMap(4:-1:2,4:-1:2));
if isempty(r)

return
end
end
end

% look for food
action = 0;
foodMap(H) = 0;
netFood = foodMap-myAntMap;
netFoodPositive = netFood > 0;
myFood = foodMap(13);
if (myFood > 0)&&(rand > (myAntMap(13)-myFood)/myAntMap(13))
lowFood = netFoodPositive&(myScentMap<myScent);
if ~any(lowFood(:))||((myFood > 1)&&(rand > sqrt(1/myFood)))
% carry home
action = 1;
myScentMap(13) = -inf;
maxScent = max(myScentMap(:));
if (maxScent == 0)
mainMap(13) = nan;
[r,c] = find(~isnan(mainMap(2:4,2:4)));
pick = ceil(rand*numel(r));
dRow = sign(r(pick)-2);
dCol = sign(c(pick)-2);
else
[r,c] = find(myScentMap==maxScent);
dRow = sign(r(1)-3);
dCol = sign(c(1)-3);
end
else
% gather lower
lowFoodPositive = lowFood > 0;
[r,c] = find(lowFoodPositive&(myScentMap==min(myScentMap(lowFoodPositive))));
dRow = sign(r(1)-3);
dCol = sign(c(1)-3);
end
elseif any(netFood(:) > 0)
% gather
[r,c] = find(netFoodPositive&(myScentMap==min(myScentMap(netFoodPositive))));
dRow = sign(r(1)-3);
dCol = sign(c(1)-3);
elseif rand>.9
% explore

mainMap(13) = nan;
[r,c] = find(~isnan(mainMap(2:4,2:4)));
pick = ceil(rand*numel(r));
dRow = sign(r(pick)-2);
dCol = sign(c(pick)-2);
else