Code viewer for Mind: Cloned New Mind

// Cloned by Velo Eire on 18 Nov 2018 from Mind "New Mind" by Velo Eire 
// Please leave this clone trail here.
// 0 LEFT (-1,y)
// 1 RIGHT (+1,y)
// 2 DOWN (x,+1)
// 3 UP (x,-1)
// 4 Do Nothing
 
function Mind() 
{ 
    
    let avoid = [];
	let playerLoc = [];
	let playerPrev = [];
	let enemyLoc = [0,0];
	let enemyPrev = [0,0];
	let flag = 0;
	var GRID= new Array(gridsize);
	var i,j, shape, thecube;
         
         for ( i = 0; i < gridsize ; i++ ){ 
                GRID[i] = new Array(gridsize); 
         }
         
	function translate ( i, j )                     
{
        var v = new THREE.Vector3();
        
        v.y =   0 ;    

        v.x = ( i * squaresize ) - ( MAXPOS/2 );                 
        v.z = ( j * squaresize ) - ( MAXPOS/2 );        
        
        return v;
}

	this.newRun = function()                  
	{
	    console.log(GRID);
	  	};

	this.getAction = function ( state )		 
	{ 
	  
	  function getEnemyAction(){
	      return(1)
	  }
	  
      var BOXHEIGHT  = squaresize;
      var wall_texture, agent_texture, enemy_texture, maze_texture; 
      
     shape= new THREE.BoxGeometry ( squaresize, BOXHEIGHT, squaresize );                  
            thecube  = new THREE.Mesh( shape );
            thecube.material = new THREE.MeshBasicMaterial( { map: maze_texture } );                  
            
            if(flag===0){
            GRID[state[0]+1][state[1]] = GRID_MAZE;
            thecube.position.copy ( translate(state[0]+1,state[1]+0) );
            ABWorld.scene.add(thecube);
            console.log("Flag = 0");
            flag = 1;
            return ( 4 );
                
            }
            if(flag===1){
            GRID[state[0]-1][state[1]] = GRID_MAZE;
            thecube.position.copy ( translate(state[0]-1,state[1]+0) );
            ABWorld.scene.add(thecube);
            console.log("Flag = 1");
            flag = 2;
            return ( 4 );
            }
            
            if(flag===2){
            GRID[state[0]][state[1]+1] = GRID_MAZE;    
            thecube.position.copy ( translate(state[0],state[1]+1) );
            ABWorld.scene.add(thecube);
            console.log("Flag = 2");
            flag = 3;
            return ( 4 );
            }
            
            if(flag===3){
            GRID[state[0]][state[1]-1] = GRID_MAZE;    
            thecube.position.copy ( translate(state[0],state[1]-1) );
            ABWorld.scene.add(thecube);
            console.log("Flag = 3");
            flag = 4;
            return ( 4 );
            }
            
            if(flag===4){
            thecube.position.copy ( translate(state[0]+1,state[1]+1) );
            GRID[state[0]+1][state[1]+1] = GRID_MAZE;
            ABWorld.scene.add(thecube);
            console.log("Flag = 4");
            flag = 5;
            return ( 4 );
            }
            
            if(flag===5){
            thecube.position.copy ( translate(state[0]-1,state[1]-1) );
            GRID[state[0]-1][state[1]-1] = GRID_MAZE;
            ABWorld.scene.add(thecube);
            console.log("Flag = 5");
            flag = 6;
            return ( 4 );
            }
            
            if(flag===6){
            thecube.position.copy ( translate(state[0]-1,state[1]+1) );
            GRID[state[0]-1][state[1]+1] = GRID_MAZE;
            ABWorld.scene.add(thecube);
            console.log("Flag = 6");
            flag = 7;
            return ( 4 );
            }
            
            if(flag===7){
            thecube.position.copy ( translate(state[0]+1,state[1]-1) );
            GRID[state[0]+1][state[1]-1] = GRID_MAZE;
            ABWorld.scene.add(thecube);
            console.log("Flag = 7");
            flag = 8;
            return ( 4 );
            }
            
            return (4);
	};

		 
	this.endRun = function()                 
	{
	};

}