public void run(ArrayList<Creature> creatures) { loc = bodyCopy.loc; vel = bodyCopy.vel; acc = bodyCopy.acc; decision.setMove(true); decision.setMoveTogheterNeigh(true); bodyCopy.addNearCreatures(creatures); bodyCopy.removeNearCreatures(); bodyCopy.addNeighbord(creatures); bodyCopy.removeNeighbord(); setNearCreatures(bodyCopy); setNeighbords(bodyCopy); setArrayNearDecisions(); setArrayNeighbordsDecisions(); action(); /* * bodyCopy.run(creatures); * * beHunted(creatures); if (isPredator && hungry < 3) { isHunting = * true; } else { isHunting = false; } // * println(relativeness(creatures,4)); */ }
// se outro é predator public void beHunted(ArrayList<Creature> creatures) { for (Creature other : creatures) { float d = PVector.dist(loc, other.loc); if (((d > 0) && (d < 40)) && (other.isPredator == true && isPredator == false)) { if (other.isHunting) { fight(other); bodyCopy.fleeFromEnemy(other); } } } }
public void stop() { if (decision.isMoving() == false) { bodyCopy.stop(); } }
public void walkTogheterNeigh(ArrayList<Creature> creatures) { if (decision.isMovingTogheterNeigh()) { bodyCopy.flock(creatures); } }
// THE ACTIONS public void walkAlone() { if (decision.isMoving()) { bodyCopy.move(); } }
public void setNearCreatures(Body b) { nearCreatures = b.getNearCreatures(); }
// /////////////////////////// // neigh public void setNeighbords(Body b) { neighbords = b.getNeighbords(); }