Code viewer for Mind: brainz
function Mind() 
{ 
		 var prevAI = 0;
		 var prevAJ = 0;
	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 strictly move away, will get stuck at wall, so introduce randomness 

		 //if ( ej < aj && !occupied(i, j+1))
		 //console.log(occupied(i, j));
		 if (ai == prevAI && aj == prevAJ)
		    return ACTION_RIGHT;
		 else
		 prevAI = ai;
		 prevAJ = aj;
		 return ACTION_UP;
        
		 /*if ( ej > aj )
		    return ACTION_DOWN; 

		 if ( ei < ai ) 
		    return ACTION_RIGHT; 
		 if ( ei > ai ) 
		    return ACTION_LEFT; 

 		return  ( AB.randomIntAtoB (0,3) );
 		*/
	};

}