function Mind()
{
this.newRun = function()
{
};
this.getAction = function ( x ) // x is an array of [ ai, aj, ei, ej ]
{
var ai = x[0];
var aj = x[1];
var ei = x[2];
var ej = x[3];
if (ai == 1)
{
if ( ej < aj ) return ( AB.randomPick ( ACTION_UP, ACTION_RIGHT ));
if ( ej > aj ) return ( AB.randomPick ( ACTION_DOWN, ACTION_RIGHT ));
else return ( AB.randomPick ( ACTION_RIGHT, AB.randomPick(ACTION_UP,ACTION_DOWN) ));
}
if (ai == 18)
{
if ( ej < aj ) return ( AB.randomPick ( ACTION_UP, ACTION_LEFT ));
if ( ej > aj ) return ( AB.randomPick ( ACTION_DOWN, ACTION_LEFT ));
else return ( AB.randomPick ( ACTION_LEFT, AB.randomPick(ACTION_UP,ACTION_DOWN) ));
}
if (aj == 1)
{
if ( ei < ai ) return ( AB.randomPick ( ACTION_UP, ACTION_RIGHT ));
if ( ei > ai ) return ( AB.randomPick ( ACTION_UP, ACTION_LEFT ));
else return ( AB.randomPick ( ACTION_UP, AB.randomPick(ACTION_RIGHT,ACTION_LEFT) ));
}
if (aj == 18)
{
if ( ei < ai ) return ( AB.randomPick ( ACTION_DOWN, ACTION_RIGHT ));
if ( ei > ai ) return ( AB.randomPick ( ACTION_DOWN, ACTION_LEFT ));
else return ( AB.randomPick ( ACTION_DOWN, AB.randomPick(ACTION_RIGHT,ACTION_LEFT) ));
}
// if (ai == 1) return ( AB.randomPick ( AB.randomPick(ACTION_UP, ACTION_DOWN), ACTION_RIGHT ));
// if (ai == 18) return ( AB.randomPick ( AB.randomPick(ACTION_UP, ACTION_DOWN), ACTION_LEFT ));
// if (aj == 1) return ( AB.randomPick ( AB.randomPick(ACTION_LEFT, ACTION_RIGHT), ACTION_UP ));
// if (aj == 18) return ( AB.randomPick ( AB.randomPick(ACTION_LEFT, ACTION_RIGHT), ACTION_DOWN ));
// if strictly move away, will get stuck at wall, so introduce randomness
if ( ej < aj ) return ( AB.randomPick ( ACTION_UP, AB.randomPick(ACTION_RIGHT,ACTION_LEFT) ));
if ( ej > aj ) return ( AB.randomPick ( ACTION_DOWN, AB.randomPick(ACTION_RIGHT,ACTION_LEFT) ));
if ( ei < ai ) return ( AB.randomPick ( ACTION_RIGHT, AB.randomPick(ACTION_UP,ACTION_DOWN) ));
if ( ei > ai ) return ( AB.randomPick ( ACTION_LEFT, AB.randomPick(ACTION_UP,ACTION_DOWN) ));
return ( AB.randomIntAtoB (0,3) );
};
this.endRun = function()
{
};
}
//AB.clockTick = 100;
//AB.maxSteps = 1000;
//AB.screenshotStep = 50;