Code viewer for Mind: Circle_mind

// Cloned by Eoin McLaughlin on 12 Nov 2018 from Mind "random_mind" by Eoin McLaughlin 
// Please leave this clone trail here.
 
 
function Mind() 
{
    
    this.distance = function(object1, object2)
    {   
        return object2[0]-object1[0]-object2[1]-object1[1]
    };  
	
	this.newRun = function()                  
	{
	    this.base_rotation = 1
	    this.direction = 0
	    this.previous_Position = [0, 0]
	    this.a = [0, 2, 1, 3]
	    this.ticker = 0
	    
	};


	this.getAction = function ( state )		 
	{
	    /*console.log(this.ticker)
	    if (this.ticker > 10)
	      {
	          this.ticker = 0
	          x = Math.random()
	          x *=4
	          x = Math.floor(x)
	          console.log(x)
	          return x
	       }*/
	    current_Enemy_Position = [state[2], state[3]]
	    current_Agent_Position = [state[0], state[1]]
	   if ((state[0] === this.previous_Position[0] && state[1] === this.previous_Position[1]))
	       this.direction = this.direction+this.base_rotation
	       if (this.direction > 3)
	            this.direction = 0
	       if (this.direction < 0)
	            this.direction = 3
	   
	   this.previous_Position = [state[0], state[1]]


       this.ticker+=1
       
       if (this.distance([state[0], state[1]], [state[2], state[3]]) < 5 )
       {
           	return this.a[this.direction]
       }
        
        else return 4

	};

		 
	this.endRun = function()                 
	{
	};

}