Code viewer for World: dank world
// Exercise
// Comment out the textures
// Comment out y and z motion



// No actual World-Mind problem
// Just blank space for Three.js experiments 
// Ignores Mind actions


 
const	 	CLOCKTICK 	= 100;				// speed of run - move things every n milliseconds
const		MAXSTEPS 	= 1000;				// length of a run before final score
 
const  SCREENSHOT_STEP = 10;   


const ARMYSIZE = 700;       // an "army" of objects 

const objectsize = 700 ;

const WALKSTEP = 20;       // bounds of the random move per timestep 
                            // try 50 (vibrating sheet) versus 1000 (cloud)
         
const MAXPOS                = 4000 ;            // start things within these bounds                    
const startRadiusConst	 	= MAXPOS * 2 ;		// distance from centre to start the camera at
const maxRadiusConst 		= MAXPOS * 5 ;		// maximum distance from camera we will render things  


const SKYCOLOR 	= 4;				// a number, not a string 
 




function randomfloatAtoB ( A, B )			 
{
 return ( A + ( Math.random() * (B-A) ) );
}

function randomintAtoB ( A, B )			 
{
 return  ( Math.round ( randomfloatAtoB ( A, B ) ) );
}
  



function World() { 

    var THEARMY 	= new Array( ARMYSIZE );	



function initArmy()		 
{
 var t = 0;
 
 for ( var c=1 ; c <= ARMYSIZE ; c++ )
 {
        var shape = new THREE.SphereGeometry ( objectsize, 10, 10 ); 
  // 	var shape = new THREE.BoxGeometry( objectsize, objectsize, objectsize );
  
  	var theobject  = new THREE.Mesh( shape );

  	theobject.position.x = randomintAtoB ( -MAXPOS, MAXPOS );   	
    theobject.position.z = randomintAtoB ( -MAXPOS, MAXPOS );   	
 	theobject.position.y =  0;	
 
 	threeworld.scene.add(theobject);
	THEARMY[t] = theobject;	            	// save it for later
	t++; 
 }
}


 

function paintArmy()        // paint objects with random textures 
{
  var textureArray = [
 	
 	( new THREE.ImageUtils.loadTexture( "/uploads/james/dbf135af1b4cd57368dae6a7cb1b5114e92e427cb82ea5f4b684c01c8256eae3_1.jpg" )),
 	( new THREE.ImageUtils.loadTexture( "/uploads/james/dankface.jpg" )),
 	( new THREE.ImageUtils.loadTexture( "/uploads/james/dankdonkey.jpg" )),
 	( new THREE.ImageUtils.loadTexture( "/uploads/james/dankdora.jpeg" ))
  	];
 	
 	
 	
 	
 	
 for ( var i = 0; i < textureArray.length; i++ )    // for all textures 
 { 
    textureArray[i].minFilter = THREE.LinearFilter;
 }
 
 
 for ( var i = 0; i < THEARMY.length; i++ )     // for all objects 
 { 
   if ( THEARMY[i] )
   { 
        var t = randomintAtoB ( 0, textureArray.length - 1 );     // random texture 
        THEARMY[i].material =  new THREE.MeshBasicMaterial ( { map: textureArray[t] } );   
   }
 }    	 
}





function moveArmy()		    // move all the objects 
{
 for ( var i = 0; i < THEARMY.length; i++ )
 { 
   if ( THEARMY[i] )
   { 
      //  THEARMY[i].position.x =  THEARMY[i].position.x + randomintAtoB(-WALKSTEP,WALKSTEP) ;        
    //   THEARMY[i].position.z =  THEARMY[i].position.z + randomintAtoB(-WALKSTEP,WALKSTEP) ;
        THEARMY[i].position.y =  THEARMY[i].position.y + randomintAtoB(0,400) ;
         
   //            THEARMY[i].position.y =  THEARMY[i].position.y + 50 ;
               
        threeworld.scene.add( THEARMY[i] );
   }
 }
}


	this.endCondition;			 


this.newRun = function() 
{
  this.endCondition = false;

  threeworld.init3d ( startRadiusConst, maxRadiusConst, SKYCOLOR  ); 

     initArmy();
	 paintArmy();	    // comment out for random coloured objects 	 
};



this.getState = function()
{
  return ( null );  
};


this.takeAction = function ( a )
{
  moveArmy();
};



this.endRun = function()
{
};


this.getScore = function()
{
 return 0;
};

}