ID:50389
Title:GT3
Author:GT
Date:2008-11-08 07:37:34
Score:31381.3585
Result:31361.95 (cyc: 4, node: 318)
CPU Time:78.7787
Status:Passed
Comments:Actually sat down and thought about it...
Based on:none
Code:
function [dRow,dCol,action,mark] = solver(mainMap,foodMap,myAntMap,opAntMap, ...
    myScentMap,opScentMap,myDeathMap,opDeathMap)

% dRow   = round(rand*2) - 1;
% dCol   = round(rand*2) - 1;
% action = -1; %-1 attack, 1 carry
% mark   =  5; % scent

%Attack when possible (algorithm only works if I am the only colony around
if(opAntMap(13)>0)
    action = -1;
    mark = 1;
    dRow  = 0;
    dCol = 0;
    return
end
points = zeros(5,5);
% If I have sugar I want come home
% head home with food
% use scent to go the same way he came
if((foodMap(13)>0)&&(mainMap(13)~=1))

    myScentMap=myScentMap.*[0 0 0 0 0;0 1 1 1 0;0 1 0 1 0;0 1 1 1 0;0 0 0 0 0 ];

    in=find(myScentMap==0);
    myScentMap(in)=NaN;
    [a,b]=max(myScentMap(:));
    myScentMap=zeros(5,5);
    myScentMap(b)=100;

    points = mainMap.*500000 ...
        + myScentMap.* 50;
    action = 1;
    mark = 10;
else

    % if I dont, I want to look for it
    % Do not head back to hill
    % if food is in sight head for it
    % move randomly if no food is in sight
    % still need to use scent only if food is found

    myScentMap=myScentMap.*[0 0 0 0 0;0 1 1 1 0;0 1 0 1 0;0 1 1 1 0;0 0 0 0 0 ];


    points = -abs(mainMap).*1e20 ...
        + foodMap.*10 ...
        + rand(5);

    action = 0;
    mark = 30;
    %never stay in the same place
    points(13)=NaN;
end

%depending on points make the best a choice:
[a,b] = max(points(:));

move = [1 1 2 3 3;
    1 1 2 3 3;
    4 4 5 6 6;
    7 7 8 9 9;
    7 7 8 9 9];

dRowop = [-1 -1 -1 0 0 0 1 1 1];
dColop = [-1 0 1 -1 0 1 -1 0 1];

dRow = dRowop(move(b));
dCol = dColop(move(b));