function in_corner(ax, ay, ex, ey){
if (ax < 3 && ay < 3) return AB.randomPick(ACTION_UP, ACTION_RIGHT);
else if (ax < 3 && ay > 15) return AB.randomPick(ACTION_DOWN, ACTION_RIGHT);
else if (ax > 15 && ay < 3) return AB.randomPick(ACTION_UP, ACTION_LEFT);
else if (ax > 15 && ay > 15) return AB.randomPick(ACTION_DOWN, ACTION_LEFT);
else return false;
}
function Mind()
{
prev_move = null;
prev_position = null;
blockers = [];
this.newRun = function()
{
};
this.getAction = function ( state )
{
var ax = state[0];
var ay = state[1];
var ex = state[2];
var ey = state[3];
var x_diff = ax - ex;
var y_diff = ay - ey;
var distance = Math.abs(x_diff) + Math.abs(y_diff);
if (prev_position == (ax, ay)){
if (prev_move == ACTION_UP) blockers.push()
}
if (Math.random() < 0.20){
move = AB.randomElementOfArray([ACTION_LEFT, ACTION_DOWN, ACTION_RIGHT, ACTION_UP]);
prev_move = move;
return move;
}
else if (in_corner(ax, ay, ex, ey)) return in_corner(ax, ay, ex, ey);
else if (distance < 5){
if(ax < ex){
if (ay < ey) return AB.randomPick(ACTION_LEFT, ACTION_DOWN);
else if (ay > ey) return AB.randomPick(ACTION_LEFT, ACTION_UP);
else return ACTION_LEFT;
}
else if (ax > ex){
if (ay < ey) return AB.randomPick(ACTION_RIGHT, ACTION_DOWN);
else if (ay > ey) return AB.randomPick(ACTION_RIGHT, ACTION_UP);
else return ACTION_RIGHT;
}
}
};
this.endRun = function()
{
};
}