// No actual problem
// Just blank space for three.js
const CLOCKTICK = 100; // speed of run - move things every n milliseconds
const MAXSTEPS = 1000; // length of a run before final score
const SCREENSHOT_STEP = 5;
const ARMYSIZE = 50;
const gridsize = 30; // number of squares along side of world
const squaresize = 100; // size of square in pixels
const MAXPOS = gridsize * squaresize; // length of one side in pixels
const SKYCOLOR = 0xccffcc; // a number, not a string
const startRadiusConst = MAXPOS * 0.8 ; // distance from centre to start the camera at
const maxRadiusConst = MAXPOS * 3 ; // maximum distance from camera we will render things
const ACTION_LEFT = 0;
const ACTION_RIGHT = 1;
const ACTION_UP = 2;
const ACTION_DOWN = 3;
const ACTION_STAYSTILL = 4;
function randomfloatAtoB ( A, B )
{
return ( A + ( Math.random() * (B-A) ) );
}
function randomintAtoB ( A, B )
{
return ( Math.round ( randomfloatAtoB ( A, B ) ) );
}
function randomBoolean()
{
if ( Math.random() < 0.5 ) { return false; }
else { return true; }
}
function World() {
var step;
var self = this;
var THEARMY = new Array( ARMYSIZE );
function translate ( x )
{
return ( x - ( MAXPOS/2 ) );
}
function loadTextures()
{
var loader2 = new THREE.TextureLoader();
loader2.load ( '/uploads/starter/pacman.jpg', function ( thetexture ) {
thetexture.minFilter = THREE.LinearFilter;
// theagent.material = new THREE.MeshBasicMaterial( { map: thetexture } );
} );
}
function initArmy()
{
var t = 0;
for ( var c=1 ; c <= ARMYSIZE ; c++ )
{
var i = randomintAtoB(1,gridsize-2);
var j = randomintAtoB(1,gridsize-2);
var shape = new THREE.BoxGeometry( squaresize, squaresize, squaresize );
var thecube = new THREE.Mesh( shape );
thecube.position.x = translate ( i * squaresize );
thecube.position.z = translate ( j * squaresize );
thecube.position.y = 0;
threeworld.scene.add(thecube);
THEARMY[t] = thecube; // save it for later
t++;
}
}
function walkArmy()
{
for ( var i = 0; i < THEARMY.length; i++ )
{
if ( THEARMY[i] )
{
THEARMY[i].position.x = THEARMY[i].position.x + randomintAtoB(86,144) ; // clone, change 20 to randomintAtoB(a,b), Q. What should a be?
THEARMY[i].position.z = THEARMY[i].position.z + randomintAtoB(46,344) ;
THEARMY[i].position.y = THEARMY[i].position.y + randomintAtoB(57,444) ;
threeworld.scene.add( THEARMY[i] );
}
}
}
this.endCondition;
this.newRun = function()
{
this.endCondition = false;
step = 0;
threeworld.init3d ( startRadiusConst, maxRadiusConst, SKYCOLOR );
initArmy();
loadTextures();
};
this.getState = function()
{
return ( null );
};
this.takeAction = function ( a )
{
step++;
walkArmy();
};
this.endRun = function()
{
};
this.getScore = function()
{
return 0;
};
}