Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.mrd.models.cagn
Class Landscape  view Landscape download Landscape.java

java.lang.Object
  extended byorg.mrd.models.cagn.Landscape

public class Landscape
extends java.lang.Object

Landscape Encapsulates much of the Internal Datastructure management of a spatial simulation. It takes care of traking agents that are dead and need to be added or removed from the simulation landscape. It is composed of Three primary data structures: 1.) Agent Grid - used to track nieghorhood relationships 2.) Resource Grid - represents available resources in an area 3.) Agent List - A randomizable or sortable list that is iterated over to update the agents. There is one secondary datastructure, a birth queue, this store new agents that need to be added to the model at the end of a iteration.


Field Summary
protected  Object2DGrid agentGrid
          Grid that holds the Agents.
protected  java.util.ArrayList agents
          A list of all the agents.
protected  java.util.Vector birthQueue
          This queue holds dispersed agents that need to be added to the simulation at the end of the iteration.
protected  Object2DGrid habitatGrid
          Grid that holds the Habitat Resources
protected  org.apache.commons.logging.Log log
           
protected  org.apache.commons.pool.ObjectPool pool
          Holds value of property model.
protected  java.util.Vector reaperQueue
          This queue holds agensts that failed to disperse that need to be removed from the simulation.
 
Constructor Summary
Landscape(org.apache.commons.pool.ObjectPool pool, java.lang.String habitatFile)
          Creates a new Landscape
 
Method Summary
 void birthAgents()
          This will update the landscape by adding the new agents to the Grid and the agent list.
 Agent getAgentAt(int x, int y)
           
 Object2DGrid getAgentGrid()
          Getter for property agentGrid.
 java.util.ArrayList getAgents()
          Getter for property agents.
 java.util.Vector getBirthQueue()
          Getter for property birthQueue.
 Object2DGrid getHabitatGrid()
          Getter for property habitatGrid.
 java.util.Vector getReaperQueue()
          Getter for property reaperQueue.
 java.lang.Object getResourceAt(int x, int y)
          This gets the Resource Object available at a (x, y) coordinate
 double getResourceValueAt(int x, int y)
          This gets the Resource double value available at a (x, y) coordinate
 int getSizeX()
          Getter for property sizeX.
 int getSizeY()
          Getter for property sizeY.
 void moveAgentTo(Agent agent, int x, int y)
           
 void moveAgentTo(int old_x, int old_y, int x, int y)
           
 void putAgentAt(int x, int y, Agent agent)
           
 void reapAgents()
          This will update the landscape by removing the dead agents from the Grid and the agent list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected org.apache.commons.logging.Log log

agentGrid

protected Object2DGrid agentGrid
Grid that holds the Agents.


habitatGrid

protected Object2DGrid habitatGrid
Grid that holds the Habitat Resources


agents

protected java.util.ArrayList agents
A list of all the agents. Convenient for any method that iterates through a list of agents. A least one list like this is common to most simulations. See below for examples of its use.


birthQueue

protected java.util.Vector birthQueue
This queue holds dispersed agents that need to be added to the simulation at the end of the iteration.


reaperQueue

protected java.util.Vector reaperQueue
This queue holds agensts that failed to disperse that need to be removed from the simulation.


pool

protected org.apache.commons.pool.ObjectPool pool
Holds value of property model.

Constructor Detail

Landscape

public Landscape(org.apache.commons.pool.ObjectPool pool,
                 java.lang.String habitatFile)
Creates a new Landscape

Method Detail

birthAgents

public void birthAgents()
This will update the landscape by adding the new agents to the Grid and the agent list.


reapAgents

public void reapAgents()
This will update the landscape by removing the dead agents from the Grid and the agent list.


getResourceAt

public java.lang.Object getResourceAt(int x,
                                      int y)
This gets the Resource Object available at a (x, y) coordinate


getResourceValueAt

public double getResourceValueAt(int x,
                                 int y)
This gets the Resource double value available at a (x, y) coordinate


getAgentAt

public Agent getAgentAt(int x,
                        int y)

moveAgentTo

public void moveAgentTo(Agent agent,
                        int x,
                        int y)

moveAgentTo

public void moveAgentTo(int old_x,
                        int old_y,
                        int x,
                        int y)

putAgentAt

public void putAgentAt(int x,
                       int y,
                       Agent agent)

getSizeX

public int getSizeX()
Getter for property sizeX.


getSizeY

public int getSizeY()
Getter for property sizeY.


getAgents

public java.util.ArrayList getAgents()
Getter for property agents.


getHabitatGrid

public Object2DGrid getHabitatGrid()
Getter for property habitatGrid.


getAgentGrid

public Object2DGrid getAgentGrid()
Getter for property agentGrid.


getBirthQueue

public java.util.Vector getBirthQueue()
Getter for property birthQueue.


getReaperQueue

public java.util.Vector getReaperQueue()
Getter for property reaperQueue.