Code viewer for Mind: random_mind
 
function Mind() 
{ 
    this.enemy_Close = function(curr_Position, enemy_Position)
    {
        if ((enemy_Position[0] - curr_Position[0] ** 2) + (enemy_Position[0] - curr_Position[0] ** 2) <= 9)
            return true
        else
            return false
    }

    
	this.compare_Lists = function(a1, a2)
    {
        return (a1[0] == a2[0]) && (a1[1] == a2[1])
    }
    
	this.newRun = function()                  
	{
	    this.direction = 0
	    this.previous_Position = [0, 0]
	};


	this.getAction = function ( state )		 
	{ 
	curr_Position = [state[0], state[1]]
	enemy_Position = [state[2], state[3]]
	var arr = [0, 1, 2, 3,];
    rand = Math.random()
    console.log(rand)
    if ( rand < 0.1 || this.compare_Lists(curr_Position, this.previous_Position))
    {
        this.direction = Math.random();
        this.direction *= arr.length; //(5)
        this.direction = Math.floor(this.direction);
    }
    
    this.previous_Position = curr_Position
    	    
	return ( this.direction );		 		
	};

		 
	this.endRun = function()                 
	{
	};

}