Code viewer for World: beep complex two3 (clone ...

// Cloned by test on 24 Jun 2019 from World "beep complex  two3" by test  
// Please leave this clone trail here.

 
 
AB.clockTick=10,AB.maxSteps=400,AB.screenshotStep=30;const TEXTURE_WALL="/uploads/starter/door.jpg",TEXTURE_MAZE="/uploads/starter/latin.jpg",TEXTURE_AGENT="/uploads/starter/pacman.jpg",TEXTURE_ENEMY="/uploads/starter/ghost.3.png",MUSIC_BACK="/uploads/starter/Defense.Line.mp3",MUSIC_ALARM="/uploads/starter/air.horn.mp3",gridsize=20,NOBOXES=Math.trunc(gridsize*gridsize/10),squaresize=100,MAXPOS=gridsize*squaresize,SKYCOLOR=14548957,BLANKCOLOR=SKYCOLOR,show3d=!0,startRadiusConst=.8*MAXPOS,skyboxConst=3*MAXPOS,maxRadiusConst=10*MAXPOS,ACTION_LEFT=0,ACTION_RIGHT=1,ACTION_UP=2,ACTION_DOWN=3,ACTION_STAYSTILL=4,GRID_BLANK=0,GRID_WALL=1,GRID_MAZE=2;function randomfloatAtoB(e,t){return e+Math.random()*(t-e)}function randomintAtoB(e,t){return Math.round(randomfloatAtoB(e,t))}function randomBoolean(){return!(Math.random()<.5)}function World(){var e,t,i,a,n,o,r,s,d,u,E=new Array(gridsize),l=new Array(4*gridsize),T=new Array(NOBOXES),c=this;function p(e,t){return a==e&&n==t||(o==e&&r==t||(E[e][t]==GRID_WALL||E[e][t]==GRID_MAZE))}function R(e){return e-MAXPOS/2}function m(){(new THREE.TextureLoader).load(TEXTURE_WALL,function(e){e.minFilter=THREE.LinearFilter,function(e){for(var t=0;t<l.length;t++)l[t]&&(l[t].material=e)}(new THREE.MeshBasicMaterial({map:e}))}),(new THREE.TextureLoader).load(TEXTURE_MAZE,function(e){e.minFilter=THREE.LinearFilter,function(e){for(var t=0;t<T.length;t++)T[t]&&(T[t].material=e)}(new THREE.MeshBasicMaterial({map:e}))}),(new THREE.TextureLoader).load(TEXTURE_AGENT,function(e){e.minFilter=THREE.LinearFilter,t.material=new THREE.MeshBasicMaterial({map:e})}),(new THREE.TextureLoader).load(TEXTURE_ENEMY,function(e){e.minFilter=THREE.LinearFilter,i.material=new THREE.MeshBasicMaterial({map:e})})}function A(){var e=R(a*squaresize),t=R(n*squaresize);i.position.x=e,i.position.y=0,i.position.z=t,threeworld.scene.add(i),threeworld.lookat.copy(i.position)}function h(){var e=R(o*squaresize),i=R(r*squaresize);t.position.x=e,t.position.y=0,t.position.z=i,threeworld.scene.add(t),threeworld.follow.copy(t.position)}function g(e){var t=o,i=r;e==ACTION_LEFT?t--:e==ACTION_RIGHT?t++:e==ACTION_UP?i++:e==ACTION_DOWN&&i--,p(t,i)||(o=t,r=i)}function f(e){37==e.keyCode&&g(ACTION_LEFT),38==e.keyCode&&g(ACTION_DOWN),39==e.keyCode&&g(ACTION_RIGHT),40==e.keyCode&&g(ACTION_UP)}this.endCondition=!1,this.newRun=function(){var c,g,B,M,w;s=0,d=0,u=0,function(){for(var e=0;e<gridsize;e++){E[e]=new Array(gridsize);for(var t=0;t<gridsize;t++)E[e][t]=GRID_BLANK}}(),function(){for(var e=0;e<gridsize;e++)for(var t=0;t<gridsize;t++)0!=e&&e!=gridsize-1&&0!=t&&t!=gridsize-1||(E[e][t]=GRID_WALL)}(),function(){for(var e=1;e<=NOBOXES;e++){var t=randomintAtoB(1,gridsize-2),i=randomintAtoB(1,gridsize-2);E[t][i]=GRID_MAZE}}(),function(){var e,t;do{e=randomintAtoB(1,gridsize-2),t=randomintAtoB(1,gridsize-2)}while(p(e,t));o=e,r=t}(),function(){var e,t;do{e=randomintAtoB(1,gridsize-2),t=randomintAtoB(1,gridsize-2)}while(p(e,t));a=e,n=t}(),show3d?(e=squaresize,threeworld.init3d(startRadiusConst,maxRadiusConst,SKYCOLOR)):(e=1,threeworld.init2d(startRadiusConst,maxRadiusConst,SKYCOLOR)),c=[new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture("/uploads/starter/dawnmountain-xpos.png"),side:THREE.BackSide}),new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture("/uploads/starter/dawnmountain-xneg.png"),side:THREE.BackSide}),new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture("/uploads/starter/dawnmountain-ypos.png"),side:THREE.BackSide}),new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture("/uploads/starter/dawnmountain-yneg.png"),side:THREE.BackSide}),new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture("/uploads/starter/dawnmountain-zpos.png"),side:THREE.BackSide}),new THREE.MeshBasicMaterial({map:THREE.ImageUtils.loadTexture("/uploads/starter/dawnmountain-zneg.png"),side:THREE.BackSide})],g=new THREE.CubeGeometry(skyboxConst,skyboxConst,skyboxConst),B=new THREE.MeshFaceMaterial(c),M=new THREE.Mesh(g,B),threeworld.scene.add(M),initMusic(),function(){for(var t=0,i=0;i<gridsize;i++)for(var a=0;a<gridsize;a++)if(E[i][a]==GRID_WALL){var n=new THREE.BoxGeometry(squaresize,e,squaresize),o=new THREE.Mesh(n);o.material.color.setHex(BLANKCOLOR),o.position.x=R(i*squaresize),o.position.z=R(a*squaresize),o.position.y=0,threeworld.scene.add(o),l[t]=o,t++}}(),function(){for(var t=0,i=0;i<gridsize;i++)for(var a=0;a<gridsize;a++)if(E[i][a]==GRID_MAZE){var n=new THREE.BoxGeometry(squaresize,e,squaresize),o=new THREE.Mesh(n);o.material.color.setHex(BLANKCOLOR),o.position.x=R(i*squaresize),o.position.z=R(a*squaresize),o.position.y=0,threeworld.scene.add(o),T[t]=o,t++}}(),w=new THREE.BoxGeometry(squaresize,e,squaresize),(t=new THREE.Mesh(w)).material.color.setHex(BLANKCOLOR),h(),function(){var t=new THREE.BoxGeometry(squaresize,e,squaresize);(i=new THREE.Mesh(t)).material.color.setHex(BLANKCOLOR),A()}(),m(),document.onkeydown=f,$("#user_span8").html("<p> 12 <p> <a href='http://google.ie'>link</a>"),$("#user_span9").html("<a target=_blank  href='http://google.ie'>link</a>")},this.getState=function(){return[o,r,a,n]},this.takeAction=function(e){var t,i;u++,function(e){var t=c.getState(),i=" Step: <b> "+u+" </b> &nbsp; x = ("+t.toString()+") &nbsp; a = ("+e+") ";$("#user_span3").html(i)}(e),g(e),u%2==0&&(a<o&&(t=randomintAtoB(a,a+1)),a==o&&(t=a),a>o&&(t=randomintAtoB(a-1,a)),n<r&&(i=randomintAtoB(n,n+1)),n==r&&(i=n),n>r&&(i=randomintAtoB(n-1,n)),p(t,i)||(a=t,n=i)),Math.abs(a-o)<2&&Math.abs(n-r)<2?s++:d++,h(),A(),function(){var e=" &nbsp; y = ("+c.getState().toString()+") <BR> ";$("#user_span4").html(e);var t=c.getScore();e="   Bad steps: "+s+" &nbsp; Good steps: "+d+" &nbsp; Score: "+t.toFixed(2)+"% ",$("#user_span5").html(e)}(),p(o-1,r)&&p(o+1,r)&&p(o,r+1)&&p(o,r-1)&&(this.endCondition=!0,d=0,musicPause(),soundAlarm())},this.endRun=function(){musicPause(),this.endCondition?$("#user_span6").html(" &nbsp; <font color=red> <B> Agent trapped. Final score zero. </B> </font>   "):$("#user_span6").html(" &nbsp; <font color=red> <B> Run over. </B> </font>   ")},this.getScore=function(){return d/u*100}}function initMusic(){var e="<audio  id=theaudio  src="+MUSIC_BACK+"   autoplay loop> </audio>";$("#user_span1").html(e)}function musicPlay(){document.getElementById("theaudio").play()}function musicPause(){document.getElementById("theaudio").pause()}function soundAlarm(){var e="<audio    src="+MUSIC_ALARM+"   autoplay  > </audio>";$("#user_span2").html(e)}