Andy Evans Living god
description
Transcript of Andy Evans Living god
/*** Starts the model going and builds an initial tribe. * * @author <A href="http://www.geog.leeds.ac.uk/people/a.evans/">Andrew Evans</A>* @version 0.1*/public class EarlyModernHumansBuilder extends DefaultContext implements ContextBuilder {
private Context context;private GridValueLayer geography;private Grid <Human> encounterGrid;private ContinuousSpace <Human> space;private Network <Human> tribalNetwork;private Parameters params;private double seaValue = 0.0;
*** Builds the spaces and an initial tribe.Each tribe has its own network, but shares continuous and grid space.*/
Andy EvansLiving god
Like rats
/*** Represents a generic Human. * This could be <I>Homo sapiens sapiens</I>, <I>Homo neanderthalensis / Homo sapiens neanderthalensis</I>, or, infact, most other hominids.* @ToDo Might be better named Hominid.java.* * @author <A href="http://www.geog.leeds.ac.uk/people/a.evans/">Andrew Evans</A>* @version 0.1*/public class Human {
/*** Makes a new tribe taking in members and a leader. * The leader should be located in space and not present in the members ArrayList.* The leader will be added to the members and the members will be distributed * around the leader in space.* @param members* @param leader*/ublic void makeTribe(ArrayList<Human> members, Human leader) {
members.add(leader);tribes.add(members);
leader.setLeader(true);leaders.add(leader);
// Move the tribe.Human tempHuman;NdPoint tempPoint;
for (int i = 1; i < members.size(); i++) {
// Setup the Human.tempHuman = members.get(i);tempPoint = getLocationCentredOnTerritory(members, 0, getTerritoryRadius(members)); space.moveTo(tempHuman, tempPoint.getX(), tempPoint.getY());
encounterGrid.moveTo(tempHuman,(int)tempPoint.getX(), (int)tempPoint.getY());tribeNetwork.addEdge(leader, tempHuman);
}}
Stroll along the Prom, Prom, Prom…
/*** Constructor.* * @param context - the primary context.* @param builder - the primary contextbuilder.* @param space - the global continuous space.* @param encounterGrid - the global grid space.* @param tribeNetwork - the globally developed tribal network.* @param initialPopulationNumber - starting population.*/public Tribes (Context context, EarlyModernHumansBuilder builder, GridValueLayer geography, ContinuousSpace <Human> space, Grid <Human> encounterGrid, Network <Human> tribeNetwork) {
this.context = context;this.builder = builder;this.geography = geography;this.space = space;this.encounterGrid = encounterGrid;this.tribeNetwork = tribeNetwork;
leaders = new ArrayList<Human>();tribes = new ArrayList<ArrayList<Human>>();
originX = geography.getDimensions().getOrigin(0);originY = geography.getDimensions().getOrigin(1);width = geography.getDimensions().getWidth() - 1;height = geography.getDimensions().getHeight() - 1;
ageSpecificFertilityRates = generateDistribution("fertility");ageSpecificDeathRates = generateDistribution("deaths");respectDistribution = generateDistribution("respect");leadershipDesireDistribution = generateDistribution("leadership");
}
Tribe
/*** Takes in an x value (age) and returns a y value (age specific fertility* rates). Distribution generated is based on a 5th order polynomial curve* from Fig.4. of: Hawkes, K. (2010) How grandmother effects plus individual* variation in frailty shape fertility and mortality: Guidance from* human–chimpanzee comparisons PNAS May 11, 2010 vol. 107 no. Supplement 2* 8977-8984 DOI: 10.1073/pnas.0914627107* http://www.pnas.org/content/107/suppl.2/8977.figures-only* * @param x* @return y*/double fertilityFunction(double x) {// Code generated by http://www.arachnoid.com/polysolve/index.htmlif ((x >= 13) || (x <= 47.5)) {double answer = 1.424485017186e+00 + -3.633942763485e-01 * x+ 3.224862325580e-02 * Math.pow(x, 2) + -1.229367715766e-03* Math.pow(x, 3) + 2.140384615644e-05 * Math.pow(x, 4)+ -1.410256410430e-07 * Math.pow(x, 5);if (answer < 0)answer = 0;return answer;} else {return 0;}}
Shopping and…
I have become DeathDestroyer of Worlds
/*** Takes in an x value (age) and returns a y value (age specific death* rates). Distribution generated is based on a 5th order polynomial curve* from Fig.10. of: Gurven, M and Kaplan, H. (2007) Longevity among* hunter-gatherers: a cross-cultural examination. Population and* Development Review 33(2):321-365.* http://www.anth.ucsb.edu/faculty/gurven/papers/GurvenKaplan2007pdr.pdf* * @param x* @return y*/ouble deathsFunction(double x) {// Code generated by http://www.arachnoid.com/polysolve/index.htmldouble answer = 1.120897832817e-01 + -1.728930697785e-02 * x+ 8.870107962213e-04 * Math.pow(x, 2) + -1.794524489958e-05* Math.pow(x, 3) + 1.359053742955e-07 * Math.pow(x, 4)+ -1.516234023974e-10 * Math.pow(x, 5);if (answer < 0)answer = 0;return answer;}
/*** Makes a new tribe taking in members and a leader. * The leader should be located in space and not present in the members ArrayList.* The leader will be added to the members and the members will be distributed * around the leader in space.* @param members* @param leader*/public void makeTribe(ArrayList<Human> members, Human leader) {
members.add(leader);tribes.add(members);leader.setLeader(true);leaders.add(leader);
// Set up the members in space.Human tempHuman;NdPoint tempPoint;
for (int i = 0; i < members.size() - 1; i++) { // NB last member is now leader.
// Setup the Human.tempHuman = members.get(i);tempPoint = getLocationCentredOnTerritory(members, 0, getTerritoryRadius(members.size()));
space.moveTo(tempHuman, tempPoint.getX(), tempPoint.getY());encounterGrid.moveTo(tempHuman,(int)tempPoint.getX(), (int)tempPoint.getY());tribeNetwork.addEdge(leader, tempHuman);
}}
Two Tribes
Parameterisation
Max tribal size = 100Random distribution around leaderTraitors = 50Fertile age = 13;Infertile age = 48;Age all die at = 81;Minimum leader age = 20;
private EarlyModernHumansBuilder builder;private Context context;private GridValueLayer geography;private Grid <Human> encounterGrid;private ContinuousSpace <Human> space;private Network <Human> tribeNetwork;private double originX;private double originY;private double width;private double height;private double[] ageSpecificFertilityRates;private double[] ageSpecificDeathRates;private int[] femaleAgeGroups;private int[] ageGroups;private int fertileAge = 13;private int infertileAge = 48;private int ageAllDieAt = 81;private int minimumLeaderAge = 20;private double f2mSexRatio = 0.47; // Based on sex ratio of 106M/100Fprivate double territoryAreaConstant = 70.0;
// See getTerritoryRadius(int populationSize)private double territoryAreaExponent = 0.70;
// See getTerritoryRadius(int populationSize)private double seaValue = 0.0;private double pixelSize = 10.0;private int maximumMembership = 100;private int traitors = 50;
/** * Generates a person excluded to a space. * At the moment we don't exclude current leaders. * @param tribe * @return A Human set up in space. Not (yet) set as a leader. */public Human excludeHuman(ArrayList<Human> tribe) {
SimUtilities.shuffle(tribe,RandomHelper.getUniform());Object[] members = tribe.toArray();Human excludee = null;Human currentLeader = leaders.get(tribes.indexOf(tribe));
// Find someone not a current leader.for (int i = 0; i < members.length; i++) {excludee = (Human) members[i];if ((excludee != currentLeader) && (excludee.getAge() >= minimumLeaderAge)) {if (Math.random() < leadershipDesireDistribution[excludee.getAge()]) {break;}}}// Exclude the Human and set them up in a space away from the tribe.tribe.remove(excludee);tribeNetwork.removeEdge(tribeNetwork.getEdge(currentLeader, excludee));
// Find new home.boolean newHomeFound = false;int minDistance = 2;int maxDistance = 3;double maximumTribeRadius = getTerritoryRadius(maximumMembership);GridPoint pt;NdPoint newHome;NdPoint currentCenter = space.getLocation(leaders.get(tribes.indexOf(tribe)));
And crawling, on the planet's face
/** * Generates a person excluded to a space. * At the moment we don't exclude current leaders. * @param tribe * @return A Human set up in space. Not (yet) set as a leader. */public Human excludeHuman(ArrayList<Human> tribe) {
SimUtilities.shuffle(tribe,RandomHelper.getUniform());Object[] members = tribe.toArray();Human excludee = null;Human currentLeader = leaders.get(tribes.indexOf(tribe));
// Find someone not a current leader.for (int i = 0; i < members.length; i++) {excludee = (Human) members[i];if ((excludee != currentLeader) && (excludee.getAge() >= minimumLeaderAge)) {if (Math.random() < leadershipDesireDistribution[excludee.getAge()]) {break;}}}// Exclude the Human and set them up in a space away from the tribe.tribe.remove(excludee);tribeNetwork.removeEdge(tribeNetwork.getEdge(currentLeader, excludee));
// Find new home.boolean newHomeFound = false;int minDistance = 2;int maxDistance = 3;double maximumTribeRadius = getTerritoryRadius(maximumMembership);GridPoint pt;NdPoint newHome;NdPoint currentCenter = space.getLocation(leaders.get(tribes.indexOf(tribe)));
some insects, called the human race.
/** * Generates a person excluded to a space. * At the moment we don't exclude current leaders. * @param tribe * @return A Human set up in space. Not (yet) set as a leader. */public Human excludeHuman(ArrayList<Human> tribe) {
SimUtilities.shuffle(tribe,RandomHelper.getUniform());Object[] members = tribe.toArray();Human excludee = null;Human currentLeader = leaders.get(tribes.indexOf(tribe));
// Find someone not a current leader.for (int i = 0; i < members.length; i++) {excludee = (Human) members[i];if ((excludee != currentLeader) && (excludee.getAge() >= minimumLeaderAge)) {if (Math.random() < leadershipDesireDistribution[excludee.getAge()]) {break;}}}// Exclude the Human and set them up in a space away from the tribe.tribe.remove(excludee);tribeNetwork.removeEdge(tribeNetwork.getEdge(currentLeader, excludee));
// Find new home.boolean newHomeFound = false;int minDistance = 2;int maxDistance = 3;double maximumTribeRadius = getTerritoryRadius(maximumMembership);GridPoint pt;NdPoint newHome;NdPoint currentCenter = space.getLocation(leaders.get(tribes.indexOf(tribe)));
Lost in time, and lost in space...
Bad god
Spreading fast if peopleBut tribes die out below max size
public void printDemographics () {
double numberOfBirths = 0; for (int age = fertileAge; age < infertileAge; age++) {numberOfBirths = numberOfBirths + ageSpecificFertilityRates[age] * femaleAgeGroups[age];
}
System.out.println("Births = " + numberOfBirths);
// Calculate the number of deaths in each age group.double[] numberOfDeaths = new
double[ageAllDieAt + 1];
for (int age = 0; age < ageAllDieAt; age++) {numberOfDeaths[age] = ageSpecificDeathRates[age] * ageGroups[age];
}
// Kill off everyone in the last age group.numberOfDeaths[ageAllDieAt] = ageGroups[ageAllDieAt];
for (int i = 0; i < ageGroups.length; i++) {System.out.println(" Age : " + i + " All : " + ageGroups[i] + " Female : " + femaleAgeGroups[i] + " Deaths : " + numberOfDeaths[i])
}
}
Et alia
The ontological status of predictions as private information
// Note that we keep a tribe-level reference the leader for // convenience, so we don't have to loop through whole
tribe to find them, // but also keep a record of whether they are leaders inside each Human // so we can display them differently (see HumanStyle.java).ArrayList<Human> tribe = new ArrayList<Human>();tribes.add(tribe);
Ship of Fool
www.geog.leeds.ac.uk/people/a.evans/
/*** Initialises the Human. Note that the spaces do not include tribal spaces, which are coped with * through the Tribe subcontext. Nevertheless, we record whether the Human * is a leader to allow HumanStyle to distinguish leaders.* @param space* @param encounterGrid*/public Human (GridValueLayer geography, ContinuousSpace
<Human> space, Grid <Human> encounterGrid) {this.geography = geography;this.space = space;this.encounterGrid = encounterGrid;}/** * Represents a generic Human. * This could be <I>Homo sapiens sapiens</I>, <I>Homo neanderthalensis / Homo sapiens neanderthalensis</I>, or, infact, most other hominids. * @ToDo Might be better named Hominid.java. * * @author <A href="http://www.geog.leeds.ac.uk/people/a.evans/">Andrew Evans</A> * @version 0.1 */