Esempio n. 1
0
  /**
   * Pass one turn. This invokes the tick() method for all Organisms, and invokes general death and
   * replication rules.
   */
  public void tick() {
    this.time++;

    // Make time pass for Organisms
    for (O o : this.getPopulation()) o.tick(this);

    // Kill dying Organisms
    for (SelectionRule<O> rule : this.settings.getDeathRules())
      for (O o : rule.select(this)) this.new Kill(o);

    // Split splitting Organisms
    for (SelectionRule<O> rule : this.settings.getSplittingRules())
      for (O o : rule.select(this)) this.new Split(o);

    // Reproduce sexy Organisms
    for (PairSelectionRule<O> rule : this.settings.getSexyRules())
      for (Pair<O, O> p : rule.select(this)) this.new Hump(p.left, p.right);

    // Execute Actions
    for (Action a : this.actions) a.execute();
    this.actions.clear();
  }