{"id":585,"date":"2012-04-16T01:54:35","date_gmt":"2012-04-16T01:54:35","guid":{"rendered":"http:\/\/www.new-territories.com\/blog\/rmit.uts\/?page_id=585"},"modified":"2012-04-30T02:48:58","modified_gmt":"2012-04-30T02:48:58","slug":"terraerosis-coding","status":"publish","type":"page","link":"https:\/\/www.new-territories.com\/blog\/rmit.uts\/code\/terraerosis-coding\/","title":{"rendered":"(terra)erosis coding"},"content":{"rendered":"<p>\/*<br \/>\n* Copyright (c) 2012 Gwyllim Jahn<br \/>\n* http:\/\/scripts.crida.net\/gh<\/p>\n<p>* Developed By Gwyllim Jahn, Mark Kowalyov and ZHU Teng Fei<br \/>\n* during the 2012 RMIT nCertainties studio.<br \/>\n*<br \/>\n* This code makes extensive use of several freely distributed<br \/>\n* processing libraries \u2013 thankyou especially to toxi.<\/p>\n<p>* This code is free software; you can redistribute it and\/or<br \/>\n* modify it under the terms of the GNU Lesser General Public<br \/>\n* License as published by the Free Software Foundation; either<br \/>\n* version 2.1 of the License, or (at your option) any later version.<br \/>\n*<br \/>\n* http:\/\/creativecommons.org\/licenses\/LGPL\/2.1\/<br \/>\n*<br \/>\n* This code is distributed in the hope that it will be useful,<br \/>\n* but WITHOUT ANY WARRANTY; without even the implied warranty of<br \/>\n* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<br \/>\n* Lesser General Public License for more details.<br \/>\n*<br \/>\n*\/<\/p>\n<p>\/\/\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013strata \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\/\/<br \/>\nimport processing.video.*;<\/p>\n<p>import processing.dxf.*;<\/p>\n<p>import processing.opengl.*;<br \/>\nimport javax.media.opengl.*;<br \/>\nimport peasy.org.apache.commons.math.*;<br \/>\nimport peasy.*;<br \/>\nimport peasy.org.apache.commons.math.geometry.*;<\/p>\n<p>import toxi.math.conversion.*;<br \/>\nimport toxi.geom.*;<br \/>\nimport toxi.geom.mesh2d.*;<br \/>\nimport toxi.util.datatypes.*;<br \/>\nimport toxi.util.events.*;<br \/>\nimport toxi.geom.mesh.subdiv.*;<br \/>\nimport toxi.geom.mesh.*;<br \/>\nimport toxi.util.*;<br \/>\nimport toxi.math.noise.*;<br \/>\nimport toxi.volume.*;<\/p>\n<p>import toxi.math.*;<br \/>\nimport controlP5.*;<br \/>\nimport toxi.color.*;<\/p>\n<p>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;Volume Params<\/p>\n<p>int DX=300;<br \/>\nint DY=300;<br \/>\nint DZ=300;<br \/>\nOscillatingVolume volumeV;<br \/>\nVolumetricBrush brushV;<br \/>\nVec3D SCALE=new Vec3D(DX,DY,DZ);<br \/>\nint sX = int(SCALE.x\/DX);<br \/>\nint sY = int(SCALE.y\/DY);<br \/>\nint sZ = int(SCALE.z\/DZ);<\/p>\n<p>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;Agent params<\/p>\n<p>\/\/==============================<br \/>\n\/\/Trail length and agent speed &#8211; obviously if you want<br \/>\n\/\/to run the agents for ages, you will need longer trails.<br \/>\n\/\/agent speed also has a significant effect on the root geom.<br \/>\nint trailLength = 200;<br \/>\nfloat agentSpeed = 1;<br \/>\n\/\/ammount to confine to a particular threshold<br \/>\nfloat confineToThreshold = 0.1;<br \/>\n\/\/distance between trail points<br \/>\nint dropSpacing = 2;<br \/>\n\/\/number of agents<br \/>\nint numAgents = 500;<\/p>\n<p>\/\/if the agent cant find a value in its neighbouring<br \/>\n\/\/voxels that is less than this number from the ideal<br \/>\n\/\/threshold (by default 0.5) =dead. LOWER=MORE DEATH<br \/>\nfloat cutoffToDie = 0.01;<br \/>\n\/\/if the agent finds a value in its neighbouring<br \/>\n\/\/voxels that is less than this number from the ideal<br \/>\n\/\/threshold (by default 0.5), then it starts counting<br \/>\n\/\/towards branching LOWER=LESS BRANCHING<br \/>\nfloat cutoffToThinkAboutBranching = 0.00015;<br \/>\n\/\/The agent needs to have been within its branching cutoff<br \/>\n\/\/for this number of steps, then it branches.<br \/>\nint numEasyMovesBeforeBranch =10;<br \/>\n\/\/number of new agents to make.<br \/>\nint splitIntoAgents=3;<\/p>\n<p>\/\/==============================<br \/>\n\/\/parameters for how the agents modify the field&#8230;<br \/>\n\/\/how big the brush is that modifies the diffusion f parameter.<br \/>\nfloat rootRadius = 2;<br \/>\nint searchRad = 3;<br \/>\n\/\/density value for the agents &#8211; a negative<br \/>\n\/\/number removes material from the diffusion,<br \/>\n\/\/numbers closer to 0 mean that more agents need to fly<br \/>\n\/\/down a similar path to actually remove the material &#8230;<br \/>\nfloat density = -0.02;<br \/>\nfloat noiseScale = 2;<\/p>\n<p>Boolean drawAgents = true;<br \/>\nBoolean saveRaw = false;<br \/>\nMovieMaker mm;<br \/>\nBoolean filming =true;<\/p>\n<p>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;Diffusion params<br \/>\nint NUM_ITERATIONS = 10;<br \/>\nControlP5 controlP5;<br \/>\nControlWindow controlWindow;<\/p>\n<p>PeasyCam cam;<br \/>\nWorld world;<\/p>\n<p>NoiseInterpolator nI = new NoiseInterpolator();<\/p>\n<p>void setup() {<br \/>\nsize(500,500,OPENGL);<br \/>\ncam = new PeasyCam(this,180);<\/p>\n<p>\/\/setup voxels<br \/>\nvolumeV=new OscillatingVolume(SCALE,DX,DY,DZ);<\/p>\n<p>brushV=new RoundBrush(volumeV,5);<\/p>\n<p>volumeV.setLandscape();<\/p>\n<p>setupP5();<\/p>\n<p>world = new World();<br \/>\nworld.spawn();<br \/>\n}<\/p>\n<p>void draw() {<br \/>\nbackground(255);<\/p>\n<p>world.update();<\/p>\n<p>volumeV.drawPoints();<\/p>\n<p>}<\/p>\n<p>void keyPressed(){<\/p>\n<p>if(key == &#8216;q&#8217;){<br \/>\nGsaveData(volumeV,&#8221;E:\/&#8221;+day()+&#8221;_&#8221;+hour()+&#8221;_&#8221;+minute()+&#8221;_&#8221;+second()+&#8221;voxels.raw&#8221;);<br \/>\n}<\/p>\n<p>if(key == &#8216;w&#8217;){<br \/>\nsavePts();<br \/>\n}<\/p>\n<p>if(key == &#8216;e&#8217;){<br \/>\nsaveParams();<br \/>\n}<\/p>\n<p>if(key == &#8216; &#8216;){<br \/>\nmm.finish();<br \/>\n}<br \/>\n}<\/p>\n<p>\/\/\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013Agent \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\/\/<br \/>\n\/\/simple agent class to interact with the data<br \/>\n\/\/field and other agents<\/p>\n<p>class Agent {<\/p>\n<p>Vec3D loc,vel,origLoc;<br \/>\nArrayList trail;<br \/>\nfloat gVal;<br \/>\nfloat dropNum;<br \/>\nboolean alive;<br \/>\nint id;<br \/>\nfloat aX,aY,aZ,lastBest;<br \/>\nint easy;<\/p>\n<p>Agent(Vec3D _loc, Vec3D _vel,int _id){<br \/>\nloc = _loc;<br \/>\nvel = _vel;<br \/>\ntrail = new ArrayList();<br \/>\ngVal = 255;<br \/>\ndropNum = 0;<br \/>\nalive = true;<br \/>\nid = _id;<br \/>\neasy = 0;<br \/>\nlastBest = 0;<br \/>\n}<\/p>\n<p>void run(){<br \/>\nif (alive){<br \/>\ngetGridPos();<br \/>\npushPullToData(true,0.5);<\/p>\n<p>\/\/branch();<\/p>\n<p>volBrushLocation();<\/p>\n<p>update();<br \/>\n}<br \/>\nrender();<br \/>\n}<\/p>\n<p>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>\/\/Behaviour for avoiding the worst (highest greyscale value) data within a proximity,<br \/>\n\/\/and interpolating the agent velocity away that point.<\/p>\n<p>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>void getGridPos(){<br \/>\naX = constrain(loc.x,0,SCALE.x);<br \/>\naX = map(aX,0,SCALE.x,0,DX);<br \/>\naY = constrain(loc.y,0,SCALE.y);<br \/>\naY = map(aY,0,SCALE.y,0,DY);<br \/>\naZ = constrain(loc.z,0,SCALE.z);<br \/>\naZ = map(aZ,0,SCALE.z,0,DZ);<br \/>\nif(loc.x&gt;SCALE.x || loc.y &gt;SCALE.y || loc.z&gt;SCALE.z)vel.invert();<br \/>\nif(loc.x }<\/p>\n<p>void pushPullToData(Boolean push, float t){<\/p>\n<p>float bestThreshDiff = 100;<br \/>\nVec3D bestThreshPt = new Vec3D(0,0,0);<\/p>\n<p>\/\/iterate over neighbouring grid pos<br \/>\nfor (int i =-searchRad;i for (int j =-searchRad;j for (int k =-searchRad; k=0&amp;&amp;(aX+i)=0&amp;&amp;(aY+j)=0&amp;&amp;(aZ+k)0.0001 &amp;&amp;val float threshVal = abs(val-t);<\/p>\n<p>if(threshVal cutoffToDie){<br \/>\nalive=false;<br \/>\nprint(&#8220;dead&#8221;);<br \/>\n}<\/p>\n<p>\/\/if in a good posy, see if we should branch<br \/>\nif(bestThreshDiff easy++;<br \/>\n}else{<br \/>\neasy = 0;<br \/>\n}<br \/>\n}<\/p>\n<p>Boolean moveToThreshold(int searchRad){<\/p>\n<p>getGridPos();<\/p>\n<p>for (int i =-searchRad;ifor (int j =-searchRad;jfor (int k =-searchRad;k=0&amp;&amp;(aX+i)=0&amp;&amp;(aY+j)=0&amp;&amp;(aZ+k)=1&amp;&amp;valnumEasyMovesBeforeBranch){<br \/>\neasy =0;<br \/>\nfor (int i = 1;i0) brushV.drawAtGridPos(aX+5,aY,aZ,-density*2);<\/p>\n<p>\/\/ if(aZ-5&gt;0) brushV.drawAtGridPos(aX,aY,aZ-5,-density*2);<br \/>\n\/\/ brushV.drawAtGridPos(aX,aY,aZ,density);<br \/>\n}<\/p>\n<p>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>\/\/Functions for managing trails and rendering the agent.<\/p>\n<p>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>void update(){<br \/>\n\/\/move the agent randomly<br \/>\nvel.normalizeTo(agentSpeed);<br \/>\n\/\/vel.interpolateToSelf(new Vec3D (0,0,1),vert);<br \/>\nloc.addSelf(vel);<\/p>\n<p>\/\/update the trail geom every 5 moves<br \/>\nif(dropNum%dropSpacing==0){<br \/>\nif(trail.size() trail.add(new Vec3D(loc.x, loc.y, loc.z));<br \/>\n}else{<br \/>\ntrail.remove(0);<br \/>\n}<br \/>\ndropNum=0;<br \/>\n}<br \/>\ndropNum++;<\/p>\n<p>}<\/p>\n<p>void render(){<br \/>\n\/\/render agent trail as lines<br \/>\nVec3D ls = null;<br \/>\nfor (Vec3D l : trail){<br \/>\nif(ls !=null){<br \/>\nstroke(0);<br \/>\nline (l.x,l.y,l.z,ls.x,ls.y,ls.z);<br \/>\n}<br \/>\nls = l;<br \/>\n}<br \/>\n}<\/p>\n<p>}<br \/>\n\/\/\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013Controllers \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\/\/<br \/>\nvoid setupP5 (){<br \/>\ncontrolP5 = new ControlP5(this);<br \/>\ncontrolP5.setAutoDraw(false);<br \/>\ncontrolWindow = controlP5.addControlWindow(&#8220;controlP5window&#8221;,100,100,400,300);<br \/>\ncontrolWindow.hideCoordinates();<\/p>\n<p>controlWindow.setTitle(&#8220;Spring GUI&#8221;);<br \/>\n\/\/\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013Oscillating Volumes \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\/\/<br \/>\nclass OscillatingVolume extends VolumetricSpaceArray {<\/p>\n<p>int z;<\/p>\n<p>public OscillatingVolume (Vec3D _S, int _DX, int _DY,int _DZ) {<br \/>\nsuper(_S,_DX,_DY,_DZ);<br \/>\nz = 0;<br \/>\n}<\/p>\n<p>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>void setLandscape(){<\/p>\n<p>for (int i=0;ifor (int j =0;jfor (int k=0;k<\/p>\n<p>\/\/create the noise field &#8211; dividing k steps the field.<br \/>\n\/\/used to emphasise the difference generated by the agents<br \/>\n\/\/setVoxelAt(i,j,k,nI.getValType(i,j,k\/4));<\/p>\n<p>\/\/use this function to make the entire field a particular type<br \/>\nsetVoxelAt(i,j,k,nI.getValType(i,j,k\/4,0));<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>void drawPoints() {<br \/>\nint r=4;<br \/>\nfor(int i=0;i for(int j=0;j for(int k=0;k=90&amp;&amp;v stroke(100);<br \/>\nline(i,j,k,i,j,k+1);<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>}<\/p>\n<p>}<br \/>\n\/\/\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013Voxel Functions \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\/\/<br \/>\npublic void GsaveData(OscillatingVolume v,String fn) {<br \/>\nprint(&#8220;saving volume data&#8230;&#8221;);<br \/>\nint c=0;<br \/>\nint tot = v.getData().length;<br \/>\ntry {<br \/>\nBufferedOutputStream ds = new BufferedOutputStream(new FileOutputStream(fn));<br \/>\n\/\/ ds.writeInt(volumeData.length);<br \/>\nfor (float element : v.getData()) {<br \/>\nif(element ds.write((int)(element*100));<\/p>\n<p>}<br \/>\nds.flush();<br \/>\nds.close();<br \/>\n} catch (IOException e) {<br \/>\ne.printStackTrace();<br \/>\n}<br \/>\n}<br \/>\n\/\/\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013World\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\/\/<br \/>\n\/\/Class to manage addition and subtraction of agents from<br \/>\n\/\/the environment<\/p>\n<p>class World {<\/p>\n<p>ArrayListagentPop;<br \/>\nArrayList newPop;<\/p>\n<p>World(){<\/p>\n<p>agentPop = new ArrayList();<br \/>\nnewPop = new ArrayList();<\/p>\n<p>}<\/p>\n<p>\/\/&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;main function<\/p>\n<p>void update(){<br \/>\nnewPop = new ArrayList();<\/p>\n<p>runAgents();<\/p>\n<p>if(newPop.size()&gt;0) addAgents();<br \/>\n}<\/p>\n<p>void runAgents(){<br \/>\nint c = 0;<br \/>\nfor (Agent a :agentPop){<br \/>\na.run();<br \/>\n}<br \/>\n}<\/p>\n<p>void addAgents(){<br \/>\nagentPop.addAll(newPop);<br \/>\n}<\/p>\n<p>void spawn(){<br \/>\nnewPop = new ArrayList();<br \/>\nagentPop = new ArrayList();<br \/>\nfor (int i=0;i \/\/ Vec3D loc = new Vec3D(random(0,gW*gRes),random(0,gH*gRes),0);<br \/>\nVec3D loc = new Vec3D(random(0,DX),random(0,DY),SCALE.z);<br \/>\nVec3D vel = new Vec3D(0,0,-3);<br \/>\nAgent a = new Agent(loc,vel,i);<br \/>\na.origLoc = loc.copy();<br \/>\nagentPop.add(a);<br \/>\n}<br \/>\n}<\/p>\n<p>void spawnOnThreshold(){<br \/>\nnewPop = new ArrayList();<br \/>\nagentPop = new ArrayList();<br \/>\nfor (int i=0;i50) searching = false;<br \/>\n}<\/p>\n<p>}<br \/>\n}<br \/>\n}<br \/>\n\/\/\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013Noise Interpolator \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\/\/<br \/>\nclass NoiseInterpolator {<\/p>\n<p>int aLimit,bLimit,cLimit,dLimit,eLimit;<br \/>\nfloat aScale,bScale,cScale,dScale,eScale;<br \/>\nfloat aContrast, bContrast, cContrast, dContrast,eContrast;<br \/>\nfloat aCompression,bCompression,cCompression,dCompression,eCompression;<\/p>\n<p>NoiseInterpolator(){<\/p>\n<p>aLimit = 0;<br \/>\naScale = 1.75;<br \/>\naContrast = 0.2;<br \/>\naCompression = 1;<\/p>\n<p>bLimit = (int)SCALE.z\/4;<br \/>\nbScale = 4;<br \/>\nbContrast = 0;<br \/>\nbCompression = 3;<\/p>\n<p>cLimit = (int)SCALE.z\/2;<br \/>\ncScale = 7;<br \/>\ncContrast = 0.35;<br \/>\ncCompression = 8;<\/p>\n<p>dLimit = (int)(SCALE.z\/4)*3;<br \/>\ndScale = 4;<br \/>\ndContrast = 0;<br \/>\ndCompression = 1;<\/p>\n<p>eLimit = (int)SCALE.z;<br \/>\neScale = 10;<br \/>\neContrast = 0;<br \/>\neCompression = 1;<br \/>\n}<\/p>\n<p>float getVal(int x, int y, int z){<\/p>\n<p>int type = floor(((float)z\/DZ)*4);<br \/>\nfloat f = ((float)z%(DZ\/4));<br \/>\nf = (f\/(DZ\/4));<\/p>\n<p>float ns = noiseScale;<br \/>\nfloat nContrast = 0;<br \/>\nfloat nCompression =1;<\/p>\n<p>if(type == 0){<br \/>\n\/\/between a and b<\/p>\n<p>ns = aScale + ( bScale &#8211; aScale ) * f;<br \/>\nnContrast = aContrast + ( bContrast &#8211; aContrast ) * f;<br \/>\nnCompression = aCompression + ( bCompression &#8211; aCompression ) * f;<\/p>\n<p>}else if (type ==1){<br \/>\n\/\/between b and c<br \/>\nns = bScale + ( cScale &#8211; bScale ) * f;<br \/>\nnContrast = bContrast + ( cContrast &#8211; bContrast ) * f;<br \/>\nnCompression = bCompression + ( cCompression &#8211; bCompression ) * f;<br \/>\n}<br \/>\nelse if (type ==2){<br \/>\n\/\/between c and d<br \/>\nns = cScale + ( dScale &#8211; cScale ) * f;<br \/>\nnContrast = cContrast + ( dContrast &#8211; cContrast ) * f;<br \/>\nnCompression = cCompression + ( dCompression &#8211; cCompression ) * f;<br \/>\n}<br \/>\nelse if (type ==3){<br \/>\n\/\/between d and &#8230;<br \/>\nns = dScale + ( eScale &#8211; dScale ) * f;<br \/>\nnContrast = dContrast + ( eContrast &#8211; dContrast ) * f;<br \/>\nnCompression = dCompression + ( eCompression &#8211; dCompression ) * f;<br \/>\n}<br \/>\nns = ns\/100;<br \/>\nfloat n = noise(x*ns,y*ns,z*ns*nCompression);<br \/>\nn = (map(n,nContrast,1-nContrast,0,1));<\/p>\n<p>return n;<br \/>\n}<\/p>\n<p>float getValType(int x, int y, int z,int type){<\/p>\n<p>float ns = noiseScale;<br \/>\nfloat nContrast = 0;<br \/>\nfloat nCompression =1;<\/p>\n<p>if(type == 0){<br \/>\n\/\/between a and b<\/p>\n<p>ns = aScale;<br \/>\nnContrast = aContrast;<br \/>\nnCompression = aCompression;<\/p>\n<p>}else if (type ==1){<br \/>\n\/\/between b and c<br \/>\nns = bScale;<br \/>\nnContrast = bContrast;<br \/>\nnCompression = bCompression;<br \/>\n}<br \/>\nelse if (type ==2){<br \/>\n\/\/between c and d<br \/>\nns = cScale;<br \/>\nnContrast = cContrast;<br \/>\nnCompression = cCompression;<br \/>\n}<br \/>\nelse if (type ==3){<br \/>\n\/\/between d and &#8230;<br \/>\nns = dScale;<br \/>\nnContrast = dContrast ;<br \/>\nnCompression = dCompression;<br \/>\n}<br \/>\nns = ns\/100;<br \/>\nfloat n = noise(x*ns,y*ns,z*ns*nCompression);<br \/>\nn = (map(n,nContrast,1-nContrast,0,1));<\/p>\n<p>return n;<br \/>\n}<\/p>\n<p>}<br \/>\n\/\/\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013saving \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\/\/<br \/>\nvoid savePts(){<br \/>\nString[] lines = new String[world.agentPop.size()];<br \/>\nint c=0;<br \/>\nfor (int i =0;i Agent a = (Agent) world.agentPop.get(i);<br \/>\nlines[c] = &#8220;&#8221;;<\/p>\n<p>for(Vec3D t:a.trail){<br \/>\nlines[c] =lines[c]+ (t.x +&#8221;,&#8221; + t.y + &#8220;,&#8221; + t.z + &#8220;\/&#8221;);<br \/>\n}<br \/>\nc++;<br \/>\n}<\/p>\n<p>saveStrings(&#8220;G:\/ncertainties\/export\/&#8221;+day()+&#8221;_&#8221;+hour()+&#8221;_&#8221;+minute()+&#8221;_&#8221;+second()+&#8221;lines.txt&#8221;, lines);<br \/>\n}<\/p>\n<p>void saveParams(){<br \/>\nString[] lines = new String[23];<br \/>\nlines[0] = &#8220;agentSpeed=&#8221;+agentSpeed;<br \/>\nlines[1] = &#8220;trailLength=&#8221;+trailLength;<br \/>\nlines[2] = &#8220;confineToThreshold=&#8221;+confineToThreshold;<br \/>\nlines[3] = &#8220;dropSpacing=&#8221;+dropSpacing;<br \/>\nlines[4] = &#8220;numAgents=&#8221;+numAgents;<br \/>\nlines[5] = &#8220;cutoffToDie=&#8221;+cutoffToDie;<br \/>\nlines[6] = &#8220;cutoffToThinkAboutBranching=&#8221;+cutoffToThinkAboutBranching;<br \/>\nlines[7] = &#8220;numEasyMovesBeforeBranch=&#8221;+numEasyMovesBeforeBranch;<br \/>\nlines[8] = &#8220;splitIntoAgents=&#8221;+splitIntoAgents;<br \/>\nlines[10] = &#8220;rootRadius=&#8221;+rootRadius;<br \/>\nlines[11] = &#8220;density=&#8221;+density;<br \/>\nlines[20] = &#8220;DX=&#8221;+DX;<br \/>\nlines[21] = &#8220;DY=&#8221;+DY;<br \/>\nlines[22] = &#8220;DZ=&#8221;+DZ;<br \/>\nsaveStrings(&#8220;G:\/ncertainties\/export\/&#8221;+day()+&#8221;_&#8221;+hour()+&#8221;_&#8221;+minute()+&#8221;_&#8221;+second()+&#8221;paramaters.txt&#8221;, lines);<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/* * Copyright (c) 2012 Gwyllim Jahn * http:\/\/scripts.crida.net\/gh * Developed By Gwyllim Jahn, Mark Kowalyov and ZHU Teng Fei * during the 2012 RMIT nCertainties studio. * * This code makes extensive use of several freely distributed * processing libraries \u2013 thankyou especially to toxi. * This code is free software; you can redistribute [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":20,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-585","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.new-territories.com\/blog\/rmit.uts\/wp-json\/wp\/v2\/pages\/585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.new-territories.com\/blog\/rmit.uts\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.new-territories.com\/blog\/rmit.uts\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.new-territories.com\/blog\/rmit.uts\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.new-territories.com\/blog\/rmit.uts\/wp-json\/wp\/v2\/comments?post=585"}],"version-history":[{"count":3,"href":"https:\/\/www.new-territories.com\/blog\/rmit.uts\/wp-json\/wp\/v2\/pages\/585\/revisions"}],"predecessor-version":[{"id":1012,"href":"https:\/\/www.new-territories.com\/blog\/rmit.uts\/wp-json\/wp\/v2\/pages\/585\/revisions\/1012"}],"up":[{"embeddable":true,"href":"https:\/\/www.new-territories.com\/blog\/rmit.uts\/wp-json\/wp\/v2\/pages\/20"}],"wp:attachment":[{"href":"https:\/\/www.new-territories.com\/blog\/rmit.uts\/wp-json\/wp\/v2\/media?parent=585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}