genome meow; int minGenes=8; int maxGenes=20; int maxRepeat=4; int maxNodes=500; int amount=int(random(minGenes,maxGenes)); scrollBar genomeScroll; PFont uiFont; boolean useGravity=false; boolean playMode=false; boolean useSmooth=false; boolean displayUI=false; boolean useMirror=true; int displayMode=1; cell selected=null; position genomeAnchor; float FRICTION_FORCE=0.999; vector GRAVITY_VECTOR=new vector(270,.1); lattice rawr; int nodeAmount=0; position rootNode; void setup() { useRK=true; size(500,500); uiFont=loadFont("KnockoutHTF30JuniorWelterwt-48.vlw"); textFont(uiFont); textMode(CORNER); ellipseMode(CENTER); rectMode(CORNER); meow=new genome(amount); rawr=new lattice(nodeAmount); genomeAnchor=new position(25,50); position scrollPos=new position(genomeAnchor.x,genomeAnchor.y-15); genomeScroll=new scrollBar(scrollPos,400); rootNode=new position(width/2,height/2+40); constructPhenome(rawr,meow); if(useMirror) mirror(rawr); // framerate(50); } void draw() { background(40); stroke(60); fill(0); rect(10,50+70,480,330); stroke(20); line(width/2,121,width/2,449); if(displayUI) doUI(); else { fill(160); textFont(uiFont,16); text("press 'h' for interface",15,470); text("press 'c' to create new creature",15,490); } playMode(); rawr.update(); display(); } void constructPhenome(lattice phen,genome gen) { float cellDistance=18; position curPos=new position(rootNode); phen.addNode(curPos,gen.strain[0]); constructChild(phen,phen.nodes[0],curPos); } void constructChild(lattice phen,cell curCell,position curPos) { if(curCell.g.repeat>0) { int r=curCell.g.repeat; if(curCell.g.id==0&&curCell.g.repeat>0) r++; position repeatPos=new position(curPos.displace(curCell.g.heading,17)); constructRepeat(phen,curCell,repeatPos,r); } if(curCell.g.child!=null&&phen.nodes.length0) { phen.addNode(curPos,curCell.g); constructRepeat(phen,curCell,curPos.displace(curCell.g.heading,17),repeat); } if(curCell.g.child!=null&&phen.nodes.length0) { gene newGene=new gene(curCell.g.child); position childPos=new position(curPos.displace(curCell.g.child.heading,17)); phen.addNode(childPos,newGene); int cellID=phen.nodes.length-1; constructChild(phen,phen.nodes[cellID],childPos); } return; } void mirror(lattice phen) { int numNodes=phen.nodes.length; for(int i=1;i