/*----------------------------------------------------------------------+
|      Title:	Range.java                                              |
|                                                                       |
|      Author:	David E. Joyce                                          |
|           Department of Mathematics and Computer Science              |
|           Clark University                                            |
|           Worcester, MA 01610-1477                                    |
|           U.S.A.                                                      |
|                                                                       |
|           http://aleph0.clarku.edu/~djoyce/                           |
|           djoyce@clarku.edu                                           |
|                                                                       |
|      Date:    May, 2002.                                              |
+----------------------------------------------------------------------*/



import java.awt.*;

public class Range {

  private int population;

  private Herd herd;

  public Range (int populationIn) {
    population = populationIn;
    herd = new Herd(population);
  }

  public void doSimulation(double deathRate, int lengthOfMatch,
                           int payoff[][],double mutationRate, double asexualRate) {
    herd.runMatch(lengthOfMatch, payoff);
    // First, remove some players due to death, randomly
    herd.death(deathRate);
    // Next, select new ones to replace the dead
    herd.birth(asexualRate);
    // Finally, mutate some of them
    herd.mutate(mutationRate);
  } // doSimulation

  public void graphUpdate (ColorGraph colorGraph) {
    colorGraph.newData(herd.getGenomeColor());
  } // graphUpdate

  public void barGraphUpdate (BarGraph barGraph) {
    Stats stats[] = herd.getStats();
    barGraph.setValues(stats);
  } // barGraphUpdate

} // Range.java


