package ail; public abstract class Agent { /** * I am currently thinking of implementing a model like DNA which has 4 possibility (2 sets). * For reproductive purposes, the scheme must match. Different species could have a * G-C pairing for a particular gene and a A-T pairing for the "same" gene. * Functionally they are equivalent, but they could not mate. * Upon creation of an agent, it takes in the appropriate gene strings and translates them * into variable settings. If we do not like this approach, all variables can be functions * which are directly mapped into the gene string. Same effect is obtained. * However, in either cases, the gene string is retained. * One of the issues that I am tossing around in my mind is the notion of a * resilience factor. For each gene, there is an associated change possibility. * Therefore, the mutations factor is two-fold: * 1) Randomly select a gene to mutate * 2) Lookup its mutation factor (also in the gene). * 3) Generate another random number. If it is within the predefined tolerance, * then allow the gene to be flipped. * * I think the biggest factor in this mutation scheme is that mutations occurring * to the factors will be the cause of rapid evolution (or devolution), not changes * to the genes themselves per se. * * BTW, mutation factors do not have mutations factors. =) */ private String gene; /** * Default Constructor */ public Agent() { } /** * Optional constructor with parents chosen */ public Agent(Agent[] parents) { } // The following items are related to reproduction and companionship /** * Returns the number of "mates" that are needed to successfully reproduce */ public int levelOfSexuality; /** * This is the "mother" gender. The children will be of this gender's class. * We could do away with this by saying that the 0 gender is the "dominant" gender. * Although, it could be cool if we make this part of the gene pool... =) */ public int dominantGender; /** * Which gender this particular agent is. * Should be less than levelOfSexuality. */ public int gender; /** * Taking the current location and then reproducing. * Yes, this function can probably be broken down as it is a bit vague... */ public abstract Agent[] reproduce(); /** * Is the Agent currently in a fertile state of its lifespan? */ public abstract boolean isFertile(); /** * This could be a cool concept. As I mentioned before, the DNA dictates the * compatibility. Therefore, any Agents with "compatible" DNA can reproduce. * For ease of use, any children are produdced by the dominant gender. */ public abstract boolean isCompatible(Agent a); /** * A factor that indicates the desire of a compatable companion */ public int companionshipLevel; /** * Does the agent like having other entities in the area */ public boolean allowOthersInArea; /** * Leadership level * We could fold this into the dominant gender. (i.e. Alpha females) * A high leadership level in an agent means that other compatible agents * are likely to follow the actions of this one. */ public int leadershipLevel; // Basic needs and information /** * Does this agent need food to survive? */ public boolean needFood; /** * Does this agent need resources to survive? */ public boolean needResources; /** * This is the life span of the agent. Probably computed at spawn time (for our ease). * The agent can still die due to hunger, death, etc. */ public int lengthOfLife; /** * Incremented each "turn" */ public int currentAge; /** * How big is the agent? * * @see grow */ public int currentSize; /** * What is the largest size this agent can be? */ public int maxSize; /** * How hungry is the agent? */ public int currentHungerFactor; /** * How sleep is the agent? * Note that some agents may not sleep */ public int currentSleepFactor; /** * How healthy is the agent? * This can be brought down by */ public int currentHealthFactor; /** * What is the highest state of health for the agent? */ public int maxHealthFactor; // methods of attacks and interactions between agents /** * Can this agent interact with a particular agent? * This will pretty much have to predefined using instanceof calls. * (i.e. a bee and a plant mix for pollen...) */ public abstract boolean canInteract(Agent a); /** * Attempts to initiate a method of attack to all "hostile" agents in the landscape * Hostiles may be definied by isCompatible method, although, we may want same * agent classes beating up on each other. * I believe that attacking and defense will be implemented much later on though. */ public abstract void attack(); /** * Called when an agent is forced to defend itself. Uses landscape to determine * agents in area. */ public abstract void defend(); /** * Called when a particular agent wishes to interact with another one */ public abstract void interact(Agent a); /** * I envision this being called by the daemon process on each turn. * This is responsible for determing what to do next. */ public abstract void nextMove(); // The following actions can be performed upon each move /** * When the agent is not fertile, it grows each "turn". * The agent can still perform another action in the same move. */ public abstract void grow(); /** * Sleep for this turn. */ public abstract void sleep(); /** * Move somewhere... */ public abstract void move(); /** * Eat this turn (based upon current location) */ public abstract void eat(); /** * Each turn the agent can take in resources from the surrounding landscape. */ public abstract Resource getInputs(); /** * Each turn the agent can release resources. */ public abstract Resource getOutputs(); /** * Allow for decomposition and resource reuse... */ public abstract boolean isAlive(); /** * GUI-related - could be called draw() as well */ public abstract void paint(); };