Code viewer for Mind: Actual New Mind

// Cloned by earlyd2 on 5 Nov 2018 from Mind "New Mind" by earlyd2 
// Please leave this clone trail here.
 

	

function Mind() 
{ 
	
	this.newRun = function()                  
	{
	};


    this.getAction = function(x)	
	{ 
	    
	 	var ai = x[0];
		var aj = x[1];
		var ei = x[2];
		var ej = x[3];

	    var dist= AB.distance2D(ai,aj,ei,ej);
	    var mid = Math.floor(gridsize / 2);

        if (dist < mid){
                if (aj <= 3 && ai <= 3)
                    return AB.randomIntAtoB(0, 4);
                else if (aj >= gridsize - 3 && ai >= gridsize - 3)
                    return AB.randomIntAtoB(0, 4);
                else if (ai >= gridsize - 3 && ai >= gridsize - 3)
                    return AB.randomIntAtoB(0, 4);
                else if (ai <= 3 && aj >= gridsize - 3)
                    return AB.randomIntAtoB(0, 4);
                
    		    else if (ej < aj  && ei < ai) 
    		        return (AB.randomPick(ACTION_UP, ACTION_RIGHT));
    		    else if( ej < aj  && ei > ai)
    		        return (AB.randomPick(ACTION_UP,ACTION_LEFT));
    		    else if( ej > aj  && ei < ai)
    		        return (AB.randomPick(ACTION_DOWN,ACTION_RIGHT));
    		    else if( ej > aj  && ei > ai)
    		        return (AB.randomPick(ACTION_DOWN,ACTION_LEFT));
    		    else
    		        return (AB.randomIntAtoB(0, 3));
            }
    		else{
    		      return ( ACTION_STAYSTILL);
    		 }
        
		    return(AB.randomIntAtoB(0,3));
	};

		 
	this.endRun = function()                 
	{
	};

}