Code viewer for Mind: New Mind
/*
 const ACTION_LEFT                       = 0;               
const ACTION_RIGHT                      = 1;
const ACTION_UP                         = 2;             
const ACTION_DOWN                       = 3;
const ACTION_STAYSTILL          = 4;
 */
 
function Mind() 
{   
    let prevX = 0;
    let prevY = 0;
    
    let goesUp = [0,1,3];
    let goesDown = [0,1,2];
    let goesLeft = [1,2,3];
    let goesRight = [0,2,3]; 
	
	this.newRun = function()                  
	{
	};


	this.getAction = function ( state )		 
	{ 
	  //console.log("Goodie Position: "+state[0]+":"+state[1]);
	  //console.log("Baddy Position: "+state[2]+":"+state[3]);
	  console.log("Previous X: "+prevX+" Current X: "+state[3]);
	  
	  if(state[3] == prevX){
	      if(state[4] > prevY){
	          prevY = state[4]
	          var rand = goesDown[Math.floor(Math.random() * goesDown.length)];
	          return(rand);
	      }
	      prevY = state[4]
	      var rand = goesUp[Math.floor(Math.random() * goesUp.length)];
	      return(rand);
	  }
	  
	  if(state[3] > prevX){
	      prevX = state[3]
	      var rand = goesRight[Math.floor(Math.random() * goesRight.length)];
	      return(rand)
	  }
	  prevX = state[3]
	  var rand = goesLeft[Math.floor(Math.random() * goesLeft.length)];
	  return(rand)
	  
	
			
	 
	  
	};

		 
	this.endRun = function()                 
	{
	};

}