function Mind()
{
this.newRun = function()
{
};
this.getAction = function(x)
{
var ai = x[0];
var aj = x[1];
var ei = x[2];
var ej = x[3];
var distance = AB.distance2D(ai,aj,ei,ej);
if (distance < Math.floor(gridsize/2)){
if (ej < aj && ei < ai) {
return (ACTION_UP, ACTION_RIGHT);
}
else if( ej < aj && ei > ai){
return (ACTION_UP,ACTION_LEFT);
}
else if( ej > aj && ei < ai){
return (ACTION_DOWN,ACTION_RIGHT);
}
else if( ej > aj && ei > ai){
return (ACTION_DOWN,ACTION_LEFT);
}
else if(ej < aj){
return(ACTION_UP,AB.randomPick3(ACTION_UP, ACTION_LEFT,ACTION_RIGHT));
}
else if(ej > aj){
return(ACTION_DOWN,AB.randomPick3(ACTION_DOWN, ACTION_LEFT,ACTION_RIGHT));
}
else if(ei < ai){
return(ACTION_RIGHT,AB.randomPick3(ACTION_RIGHT, ACTION_UP,ACTION_DOWN));
}
else if(ei > ai){
return(ACTION_LEFT,AB.randomPick3(ACTION_LEFT, ACTION_UP,ACTION_DOWN));
}
else {
return(AB.randomIntAtoB(0,3));
}
}
else {
return ( ACTION_STAYSTILL);
}
};
this.endRun = function()
{
};
}