Code viewer for Mind: Cloned Run Forrest Run

// Cloned by Solanm3 on 19 Nov 2018 from Mind "Run Forrest Run" by Solanm3 
// Please leave this clone trail here.
 
function Mind() 
{ 
	
	this.newRun = function()   //org func               
	{
	    
        const ACTION_LEFT       = 0;               
        const ACTION_RIGHT      = 1;
        const ACTION_UP         = 2;             
        const ACTION_DOWN       = 3;
        const ACTION_STAYSTILL  = 4;
        const BLOCKPUNISH       = 1;
        
        var ei, ej, ai, aj;
	};

    AB.clockTick = 10;    // Speed of run
    

    AB.maxSteps = 2500 ;    // Length of run    


    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)     return (AB.randomPick ( ACTION_UP, AB.randomPick(ACTION_RIGHT,ACTION_LEFT))); 
                 if (ej > aj)     return (AB.randomPick ( ACTION_DOWN, AB.randomPick(ACTION_RIGHT,ACTION_LEFT))); 
                 if (ei < ai)     return (AB.randomPick ( ACTION_RIGHT,  AB.randomPick(ACTION_UP,ACTION_DOWN))); 
                 if (ei > ai)     return (AB.randomPick ( ACTION_LEFT,   AB.randomPick(ACTION_UP,ACTION_DOWN))); 

                return  (AB.randomIntAtoB (0,3));
        };        
                
	this.endRun = function() // org func                
	{
	    console.log("Game Log"); 
	};
}