/* * (c) 1998-2000 The Brookings Institution, All Rights Reserved * * Permission to use this software and its documentation for non-commercial * purposes and without fee is hereby granted, provided this copyright statement * is included. Please contact us for permission for redistribution and other uses. *  * BROOKINGS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,  * OR NON-INFRINGEMENT. BROOKINGS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY * LICENSEE AS A RESULT OF USING THIS SOFTWARE OR ITS DERIVATIVES. * * _Sugarscape_ * See _Growing Artificial Societies: Social Science from the Ground Up_ * Brookings Institution Press, The MIT Press * Joshua Epstein * jepstein@brook.edu * Robert Axtell * raxtell@brook.edu * * Miles Parker * mparker@brook.edu * http://www.brook.edu/es/dynamics/models/ascape * The Brookings Institution * Washington, D.C. */package edu.brook.sugarscape;import java.lang.*;import java.util.*;import java.awt.Color;import edu.brook.ascape.model.*;import edu.brook.ascape.util.*;public class SexualAgent extends SugarAgent {        protected static int minReproductionBeginsAge = 12;        protected static int maxReproductionBeginsAge = 15;    protected static int minFemaleReproductionEndsAge = 40;    protected static int maxFemaleReproductionEndsAge = 50;    protected static int minMaleReproductionEndsAge = 50;        protected static int maxMaleReproductionEndsAge = 60;        protected static int minInitialSugar = 50;    protected static int maxInitialSugar = 100;        public boolean female;        protected float initialSugarEndowment;        protected int beginReproductionAge;        protected int endReproductionAge;        public void initialize() {        super.initialize();        initialSugarEndowment = getSugar().getStock();        female = randomIs();        beginReproductionAge = randomInRange(minReproductionBeginsAge, maxReproductionBeginsAge);        if (female) {            endReproductionAge = randomInRange(minFemaleReproductionEndsAge, maxFemaleReproductionEndsAge);        }        else {            endReproductionAge = randomInRange(minMaleReproductionEndsAge, maxMaleReproductionEndsAge);        }    }        public void setVision(int vision) {        super.setVision(vision);    }        public void setSugarMetabolism(int metabolism) {        super.setSugarMetabolism(metabolism);    }        public float getContributionToChild() {        return initialSugarEndowment / 2;    }        public boolean isFertile() {        return ((getSugar().getStock() >= initialSugarEndowment) && (age >= beginReproductionAge) && (age <= endReproductionAge));    }        public boolean isMale() {        return !female;    }        public boolean isFemale() {        return female;    }        public void setFemale(boolean female) {        this.female = female;    }}
