Code viewer for Mind: Cloned Ancient Brain Assig...

// Cloned by James O'Boyle on 26 Nov 2018 from Mind "Ancient Brain Assignment - CA318" by James O'Boyle 
// Please leave this clone trail here.
 
 
function Mind() 
{ 

	this.newRun = function()                  
	{
	    
	};


	this.getAction = function ( state )		 
	{ 
        var left = 0;
        var right = 1;
        var up = 2;
        var down = 3;
        var random_action = AB.randomIntAtoB(0,3)
        var ax = state[0] 
        var ay = state[1] 
        var ex = state[2] 
        var ey = state[3]
        
    //if (AB.randomBoolean())
    //{
        // if ( ex < ax && ey == ay ) 	    return (  right );
        // if ( ex > ax && ey == ay ) 	    return (  left  );
    //}
    //else
    //{
        // if ( ex == ax && ey > ay ) 	    return (  down  );
        // if ( ex == ax && ey < ay ) 	    return (  up    );
    //}
    //return(random_action)
	 
	// if ( ex < ax && ey > ay ) 	    return (  down || right );
	// if ( ex > ax && ey > ay )  	return (  down || left  );
	// if ( ex < ax && ey < ay ) 	    return (  up   || right   );
	// if ( ex > ax && ey < ay ) 	    return (  up   ||  left   );
	
    if (AB.randomBoolean())
    {
     if ( ey < ay ) 	return ( up    );
	 if ( ey > ay ) 	return ( down  );
    }
    else
    {
	 if ( ex < ax  ) 	return (  right  );
	 if ( ex > ax  ) 	return (  left   );
    }
    
 	return  (random_action);
	 
	};

		 
	this.endRun = function()                 
	{
	    
	};

}