Code viewer for Mind: Dan and Jacob mind
function Mind() 
{
	
	this.newRun = function()                  
	{
	};


    const ACTION_LEFT = 0;
    const ACTION_RIGHT = 1;
    const ACTION_UP = 2;
    const ACTION_DOWN = 3;  
    const ACTION_STAYSTILL = 4;


	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];
	

    // Where not enemy
    // 	go right >  if right is more than up and down   & right is not wall
    // 	go up   >   if up is more than left             & up is not wall
    // 	go left >   else
    // 	go down >   else
	

	if ((ei < ai) & ((ai - ei)>(aj-ej)||(ai - ei)>(ej-aj)))   return (AB.randomPick( ACTION_RIGHT, AB.randomPick(ACTION_DOWN, ACTION_UP))); //e is l  
    if ((ej < aj) & (aj-ej)>(ei-ai))                          return (AB.randomPick( ACTION_UP, AB.randomPick(ACTION_RIGHT, ACTION_LEFT))); //e is below
	if ( (ei > ai) )                              return (AB.randomPick( ACTION_LEFT, AB.randomPick(ACTION_DOWN, ACTION_UP))); //e is r
	if ( (ej > aj) )                             return (AB.randomPick( ACTION_DOWN, AB.randomPick(ACTION_RIGHT, ACTION_LEFT))); //e is up
	
	return ACTION_STAYSTILL
	
	this.endRun = function()                 
	{
	};
	};
}