// SEM DNA VVVVVV public Creature( PApplet _p, int _id, PVector _loc, boolean _mouth, boolean _eye, boolean _ear, boolean _nose, boolean _hand, boolean _leg, boolean _reproductive, boolean _isPredator) { myHash = this.hashCode(); p = _p; id = _id; isPredator = _isPredator; loc = _loc; acc = new PVector(0, 0); vel = new PVector(p.random(-1, 1), p.random(-1, 1)); dna = new DNA(); // numero fixos de neurons dna.setGene(0, 0.02f); // in dna.setGene(1, 0.03f); // hidden dna.setGene(2, 0.02f); // out dna.setGene(3, 0.25f); // learn // fitness = random(1); brainInput = p.round(dna.getGene(0) * 100); brainHidden = p.round(dna.getGene(1) * 100); brainOutput = p.round(dna.getGene(2) * 100); // println("input: " + brainHidden); // muitas das capacidades do cérebro são herdadas pelo dna // UTILIZAR MAIS DE UM "BRAIN" PARA SEPARAR FUNCIONALIDADES brain = new Brain(dna); // movementCortex = new Brain(dna); // socialCortex = new Brain(dna); // enviromentCortex = new Brain(dna); haveMouth = _mouth; haveEye = _eye; haveEar = _ear; haveNose = _nose; haveHand = _hand; haveLeg = _leg; haveReproductive = _reproductive; decision = new Decision(); // //toda criatura tem um corpo físico com habilidades de movimento bodyCopy = new Body(p, dna, loc, vel, acc, myHash); creatureDrawer = new CreatureDrawer(p, dna, loc, vel); }
// MÉTODOS DE PROCRIAÇÃO // TODO: métodos de geração (por gestação, ovos etc) public Creature copulate(ArrayList<Creature> creatures) { Creature c = null; for (Creature other : creatures) { DNA partner = other.dna; if (relativeness(creatures, 3, 297, 391) == true) { DNA childDNA = dna.mate(partner); childDNA.mutate(0.01f); // mudar (isPredator) c = new Creature( childDNA, p.round(p.random(9999999)), loc, true, true, true, true, true, true, true, false); } } return c; }
protected void setInternalValue(float theValue) { // TODO simplify below code. // TODO rename modifiedValue and currentValue to make it more obvious to // what these variables refer to modifiedValue = (isSnapToTickMarks) ? PApplet.round((theValue * _myTickMarksNum)) / ((float) _myTickMarksNum) : theValue; currentValue = theValue; myAngle = PApplet.map( isSnapToTickMarks == true ? modifiedValue : currentValue, 0, 1, startAngle, startAngle + range); if (isSnapToTickMarks) { if (previousValue != modifiedValue && isSnapToTickMarks) { broadcast(FLOAT); previousValue = modifiedValue; return; } } if (previousValue != currentValue) { broadcast(FLOAT); previousValue = modifiedValue; } }
@SuppressWarnings("static-access") public int getColor() { if (_colorList.size() <= 0) return 0; PApplet app = H.app(); int index = app.round(app.random(_colorList.size() - 1)); return _colorList.get(index); }
// tätä käytin debuggailutilassa; pelaaja värjäsi tilet joissa oli käynyt jo eri värille void visit(PVector point) { int x = PApplet.round(point.x); int y = PApplet.round(point.y); int z = PApplet.round(point.z); map[at(x, y, z)] = 0xffffffff; }
void dobox(PGraphics pa, PVector p, int color) { dobox(pa, PApplet.round(p.x), PApplet.round(p.y), PApplet.round(p.z), color); }
int at(PVector p) { return at(PApplet.round(p.x), PApplet.round(p.y), PApplet.round(p.z)); }
// onko kalikkaa tässä kohdassa? peliobjektit tarkistavat putoamisen näin boolean hasBlk(PVector point) { int x = PApplet.round(point.x); // round int y = PApplet.round(point.y); int z = PApplet.round(point.z); return x >= 0 && y >= 0 && z >= 0 && x < size && y < size && z < size && map[at(x, y, z)] != 0; }