Code viewer for Mind: New Mind
 
function Mind() 
{ 
	
	this.newRun = function()                  
	{
	};


	this.getAction = function ( state )		 
	{
	var ax = state[0];
	var ay = state[1];
	var ex = state[2];
	var ey = state[3];
	
	if (ax == 1 && ay == 1)
	{
	    return AB.randomPick(ACTION_UP, ACTION_RIGHT);
	}
	
	if (ax == 1 && ay == 18)
	{
	    return AB.randomPick(ACTION_DOWN, ACTION_RIGHT);
	}
	
	if (ax == 18 && ay == 1)
	{
	    return AB.randomPick(ACTION_UP, ACTION_LEFT);
	}
	
	if (ax == 18 && ay == 18)
	{
	    return AB.randomPick(ACTION_DOWN, ACTION_LEFT);
	}
	
	if(ey < ay) return(AB.randomPick(ACTION_UP, AB.randomPick(ACTION_RIGHT, ACTION_LEFT)));
	if(ey > ay) return(AB.randomPick(ACTION_DOWN, AB.randomPick(ACTION_RIGHT, ACTION_LEFT)));
	if(ex < ax) return(AB.randomPick(ACTION_RIGHT, AB.randomPick(ACTION_UP, ACTION_DOWN)));
	if(ex > ax) return(AB.randomPick(ACTION_LEFT, AB.randomPick(ACTION_UP, ACTION_DOWN)));
	};
	
	this.endRun = function()                 
	{
	};

}