class creature { float fitness; genome genotype; int minGenes=25; int maxGenes=30; int maxRepeat=3; int maxNodes=500; // int amount=int(random(minGenes,maxGenes)); int amount=15; position rootNode; lattice phenotype; int nodeAmount=0; float cohesionDistance=30; float minDistance=15; float collisionDistance=12; position lastP; position p; float distanceTravelled=0; boolean allTypes=false; creature(position startPos) { rootNode=new position(startPos); genotype=new genome(amount,this); phenotype=new lattice(nodeAmount,this); buildCreature(rootNode,phenotype,genotype,maxNodes); phenotype.update(); p=new position(phenotype.averagePos); lastP=new position(p); distanceTravelled=0; allTypes=checkCompletion(); tagGenome(); } creature(creature c) { fitness=0; rootNode=new position(c.rootNode); minGenes=c.minGenes; maxGenes=c.maxGenes; maxNodes=c.maxNodes; maxRepeat=c.maxRepeat; amount=c.amount; nodeAmount=c.nodeAmount; cohesionDistance=c.cohesionDistance; collisionDistance=c.collisionDistance; minDistance=c.minDistance; genotype=new genome(c.genotype,this); phenotype=new lattice(nodeAmount,this); //rebuild(); //phenotype=new lattice(c.nodeAmount,this); buildCreature(rootNode,phenotype,genotype,maxNodes); phenotype.update(); p=new position(phenotype.averagePos); lastP=new position(p); distanceTravelled=0; allTypes=checkCompletion(); tagGenome(); } creature(position startPos,genome g) { rootNode=new position(startPos); genotype=new genome(g,this); phenotype=new lattice(nodeAmount,this); buildCreature(rootNode,phenotype,genotype,maxNodes); phenotype.update(); p=new position(phenotype.averagePos); lastP=new position(p); distanceTravelled=0; allTypes=checkCompletion(); tagGenome(); } void update(position l) { lastP=new position(p); phenotype.update(l); p=new position(phenotype.averagePos); distanceTravelled+=dist(lastP,p); } boolean checkCompletion() { return phenotype.allTypes(); } boolean checkStability() { return phenotype.stable; } float currentSize() { return phenotype.mostDistant; } void export(String filename) { String list[]=split(genotype.strainKey); saveStrings(filename,list); } void rebuild() { genotype.clearTags(); phenotype=new lattice(nodeAmount,this); buildCreature(rootNode,phenotype,genotype,maxNodes); phenotype.update(); p=phenotype.averagePos; lastP=new position(p); distanceTravelled=0; tagGenome(); } void mutate() { if(random(100)>50) for(int m=0;m<8;m++) genotype.mutateMorph(); else for(int m=0;m<8;m++) genotype.mutateNS(); } void tagGenome() { for(int p=0;p