public int turnRight(Organism target, int index) { double cost = 0.25 * energyMod; target.setAngle(target.getAngle() - turnMod); target.drainEnergy(cost); return index + 1; }
public int ifSightHit(Organism target, int index) { double cost = 0.25 * energyMod; target.drainEnergy(cost); if(target.getSight().canSee()) { return index + 1; } else { return index + 2; } }
public int moveForward(Organism target, int index) { double cost = 0.25 * energyMod; Point proposedPosition = new Point(); proposedPosition.X = target.getPosition().X + (Math.Sin(target.getAngle()) * target.getSpeed() * moveMod); proposedPosition.Y = target.getPosition().Y + (Math.Cos(target.getAngle()) * target.getSpeed() * moveMod); if(proposedPosition.X < world.getWorldSize().X & proposedPosition.X > 0) { if(proposedPosition.Y < world.getWorldSize().Y & proposedPosition.Y > 0) { target.modifyPosition(proposedPosition); target.drainEnergy(cost * calculateSpeedCost(target.getSpeed())); } } target.drainEnergy(cost * calculateSpeedCost(target.getSpeed()) + 0.25); return index + 1; }