/*----------------------------------------------------------------------+ | 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/home.html | | djoyce@clarku.edu | | | | Date: February, 2001. | +----------------------------------------------------------------------*/ import java.awt.event.*; import java.awt.Color; public class Range extends Thread { // constants final int max_n_herds = 200; // parameters int cost; // cost to altruist in 10ths of a unit int benefit; // benefit from altruist in 10ths of a unit int herd_size; // each herd has this population int init_alt; // how many initial altruists int n_herds; // the number of herds int deaths; // this many die and are born each day in each herd int max_days; // how many days to run the simulation int band_size; // each migrating band has this size int migration_period; // how many days between migrations int timeout; // milliseconds between days // herds are arranged in a circle. Each migration period a band leaves // each to go to its two neighbors Herd H[]; // the herds Herd L[]; // the left moving bands Herd R[]; // the right moving bands int day; Moth V; RangeDisplay display; TimeGraph totStats; TimeGraph indivStats; boolean running = false; Range (Moth V_init) { V = V_init; H = new Herd[max_n_herds]; L = new Herd[max_n_herds]; R = new Herd[max_n_herds]; } void reset(int cost_init, int benefit_init, int hs_init, int ia_init, int nh_init, int deaths_init, int md_init, int bs_init, int mp_init, int timeout_init) { cost = cost_init; benefit = benefit_init; herd_size = hs_init; init_alt = ia_init; n_herds = nh_init; deaths = deaths_init; max_days = md_init; band_size = bs_init; migration_period = mp_init; timeout = timeout_init; resetHerds(); } void addStats(TimeGraph ts, TimeGraph is) { totStats = ts; indivStats = is; } public String toString() { String S = "n_herds="+n_herds; for (int i=0; i