2005-05-18 09:00:00 UTC

Status: Failed
Results:

Rohit Ingale
18 May 2005
Based on soolver2
Code
```function [dy,dx,mark,carry]=solver(main,food,ants,scent)
%18372.39
rand(1,5);
i35=3:5;
i24=2:4;
i02=0:2;
% find reachable regions
end
end
end
end
% modify current board based on reachable regions
end
% setup game stats
scents=scent(scent>0);
maxscent=max(scents(:));
% mark this field
if (max(main(:))>0)
mark=400-scent(13);
scent(13)=400;
init=0;
hills=find(main>0);
scent(hills)=1e7;
food(hills)=0;
if isempty(scents);maxscent=mark;end
elseif (maxscent==min(scents(:))) % init phase
mark=maxscent-scent(13);
scent(13)=maxscent;
init=1;
elseif isempty(scents) % nothing is marked
mark=98;
scent(13)=scent(13)+98;
maxscent=mark;
init=1;
else
mark=maxscent-1-scent(13);
scent(13)=maxscent-1;
init=0;
end
% look around for food
if max(food(:))<1 ||init % nothing found or no way home, search
[y,x]=find(target(i24,i24)==max(target(:)));
[y,x]=find(target==max(target(:)));
if (numel(y)>1)
r=ceil(rand*numel(y));
y=y(r);
x=x(r);
end
carry=food(13)>0;
if((y>0) && (x>0))
dy=y-3;
dx=x-3;
return;
end;
m(7,7)=0;
m(y+i02,x+i02)=1;
m=m(i35,i35);
t=target(i24,i24).*m+m;
[dy,dx]=find(t==max(t(:)));
r=ceil(rand*numel(dy));
dy=dy(r)-2;
dx=dx(r)-2;
return;
end;
if (food(13)>1)&&rand<.95 % sit on a lot of food, go home
[y,x]=find(target==max(target(:)));
if (numel(y)>1)
y=y(1);
x=x(1);
end
carry=1;
if((y>0) && (x>0))
dy=y-3;
dx=x-3;
return;

m(7,7)=0;
m(y+i02,x+i02)=1;
m=m(i35,i35);
t=target(i24,i24).*m+m;
[dy,dx]=find(t==max(t(:)));
r=ceil(rand*numel(dy));
dy=dy(r)-2;
dx=dx(r)-2;
return;
end;
if (food(13) >= 1) % sit on one food, build track
[yhome,xhome]=find(target==max(target(:)));
lowfood=food.*(scent<scent(13));
carry=1;
dhere=max(max(abs(yhome-3),abs(xhome-3)));
emph=ones(5);
emph(i24,i24)=1e8;
runs=numel(find(lowfood(:)>0));
while runs % fetch food behind
[y,x]=find(target==max(target(:)));
if (numel(y)>1)
r=ceil(rand*numel(y));
y=y(r);
x=x(r);
end
if((y>0) && (x>0))
dy=y-3;
dx=x-3;
return;
else
m(7,7)=0;
m(y+i02,x+i02)=1;
m=m(i35,i35);
t=target(i24,i24).*m+m;
[dy,dx]=find(t==max(t(:)));
r=ceil(rand*numel(dy));
dy=dy(r)-2;
dx=dx(r)-2;
end
dthere=min(max(abs(yhome-y),abs(xhome-x)));
if (dthere>dhere)
carry=0;
return;
end
target(y,x)=0;runs=runs-1;
end
if (carry) % go home
[y,x]=find(target==max(target(:)));
if (numel(y)>1)
r=ceil(rand*numel(y));
y=y(r);
x=x(r);
end
if((y>0) && (x>0))
dy=y-3;
dx=x-3;
return;

m(7,7)=0;
m(y+i02,x+i02)=1;
m=m(i35,i35);
t=target(i24,i24).*m+m;
[dy,dx]=find(t==max(t(:)));
r=ceil(rand*numel(dy));
dy=dy(r)-2;
dx=dx(r)-2;
end
return;
end;
[y,x]=find(target==max(target(:)));
if (numel(y)>1)
r=ceil(rand*numel(y));
y=y(r);
x=x(r);
end
carry=0;
if((y>0) && (x>0))
dy=y-3;
dx=x-3;
return;
m(7,7)=0;
m(y+i02,x+i02)=1;
m=m(i35,i35);
t=target(i24,i24).*m+m;
[dy,dx]=find(t==max(t(:)));
r=ceil(rand*numel(dy));
dy=dy(r)-2;
dx=dx(r)-2;```