Code viewer for Mind: Cloned yo

// Cloned by tuitef2 on 18 Nov 2018 from Mind "yo" by tuitef2 
// Please leave this clone trail here.
 


// Cloned by tuitef2 on 18 Nov 2018 from Mind "New Mind" by tuitef2 
// Please leave this clone trail here.
 
 
function Mind() 
{ 
	
	this.newRun = function()                  
	{
	};


	this.getAction = function ( state )		 
	{ 
	  prev = [-100,-100];
	  var x = state[0];
	  var y = state[1];
	  var x1 = state[2];
	  var y1 = state[3];
	  
	  good = [x,y]; //x, y co-ords of good bot
	  bad = [x1,y1]; // x, y co-ords of bad bot
	  moves = function(){
    	  movez = [[0,0],[0,0],[0,0],[0,0]]; // calculating the sides of good, front, back, right, left
    	  if (1 != good[1]){
    	      movez[0] = [good[0],good[1]-1]; //!= 1 as theres only 3 sides in the 1 position on the grid
    	  }
    	  if (1 != good[0]){
    	      movez[1] = [good[0]-1,good[1]];
    	  }
    	  if (18 != good[1]){
    	      movez[2] = [good[0],good[1]+1]; //!=18 as theres only 3 sides in the 18 position on the grid 
    	  }
    	  if (18 != good[0]) {
    	      movez[3] = [good[0]+1,good[1]];
    	  }
	    return movez;
	  };
	  best_move = function(){
	      moves = moves();
	      var best = 0;
	      var bm = [-100,-100]; //min and max x and y 
	      
	      for (i = 0; i < moves.length; i++){
	          distance = moves[i][0] - bad[0] + (moves[i][1] - bad[1]); //distance between good, bad x and y 
	          if (distance > best){
	              best = distance;
	              bm[0] = moves[i][0];
	              bm[1] = moves[i][1];
	          }
	          console.log('d', distance, 'best move', bm);
	      }
        return bm;
	  };
	  move = function(good,bad){
	    if (good.stuckfor < 2)
            return AB.randomIntAtoB(0, 3);
        if (AB.randomBoolean()) {
            if (good[0] < bad[0])
                return 1;
            if (good[1] < bad[1])
                return 2;
        }
        else{
            if (good[0] > bad[0])
                return 0;
        }
        return 3;
    };
	  best_move = best_move();
	  move = move(good,best_move);
	  console.log('mv',move);
	  if (prev[0] == best_move[0] & prev[1] == best_move[1]){
	      move = AB.randomIntAtoB(0,3);
	      prev = best_move;
	      console.log('prev',prev);
	  }
	  return move;
	};

		 
	this.endRun = function()                 
	{
	};

}