org.mrd.repast.landscape
Class Landscape

java.lang.Object
  |
  +--org.mrd.repast.landscape.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.) LandscapeAgent Grid - used to track nieghorhood relationships 2.) Resource Grid - represents available resources in an area 3.) LandscapeAgent 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.

Author:
Mark Diggory ;

Field Summary
protected  uchicago.src.sim.space.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 new agents that need to be added to the simulation at the end of the iteration.
protected  uchicago.src.sim.space.Object2DGrid habitatGrid
          Grid that holds the Habitat Resources
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
Landscape(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.
 LandscapeAgent getAgentAt(int x, int y)
           
 uchicago.src.sim.space.Object2DGrid getAgentGrid()
          Getter for property agentGrid.
 java.util.ArrayList getAgents()
          Getter for property agents.
 uchicago.src.sim.space.Object2DGrid getHabitatGrid()
          Getter for property habitatGrid.
 org.apache.commons.pool.ObjectPool getPool()
          Getter for property pool.
 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(int old_x, int old_y, int x, int y)
           
 void moveAgentTo(LandscapeAgent agent, int x, int y)
           
 void putAgentAt(int x, int y, LandscapeAgent agent)
           
 void reapAgents()
          This will update the landscape by removing the dead agents from the Grid and the agent list.
 void setPool(org.apache.commons.pool.ObjectPool pool)
          Setter for property pool.
 
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 uchicago.src.sim.space.Object2DGrid agentGrid
Grid that holds the Agents.


habitatGrid

protected uchicago.src.sim.space.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 new agents that need to be added to the simulation at the end of the iteration.

Constructor Detail

Landscape

public Landscape(java.lang.String habitatFile)
Creates a new Landscape

Parameters:
habitatFile - The Habitat File that will initialize the resources in this 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

Parameters:
x - coordinate
y - coordinate
Returns:
Object The resource object at the coordinate of the LandscapeAgent

getResourceValueAt

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

Parameters:
x - coordinate
y - coordinate
Returns:
double The value of the resource object at that coordinate.

getAgentAt

public LandscapeAgent getAgentAt(int x,
                                 int y)
Parameters:
x -
y -
Returns:

moveAgentTo

public void moveAgentTo(LandscapeAgent agent,
                        int x,
                        int y)
                 throws java.lang.Exception
Parameters:
x -
y -
agent -
java.lang.Exception

moveAgentTo

public void moveAgentTo(int old_x,
                        int old_y,
                        int x,
                        int y)
                 throws java.lang.Exception
Parameters:
x -
y -
java.lang.Exception

putAgentAt

public void putAgentAt(int x,
                       int y,
                       LandscapeAgent agent)
                throws java.lang.Exception
Parameters:
x -
y -
agent -
java.lang.Exception

getSizeX

public int getSizeX()
Getter for property sizeX.

Returns:
Value of property sizeX.

getSizeY

public int getSizeY()
Getter for property sizeY.

Returns:
Value of property sizeY.

getAgents

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

Returns:
Value of property agents.

getHabitatGrid

public uchicago.src.sim.space.Object2DGrid getHabitatGrid()
Getter for property habitatGrid.

Returns:
Value of property habitatGrid.

getAgentGrid

public uchicago.src.sim.space.Object2DGrid getAgentGrid()
Getter for property agentGrid.

Returns:
Value of property agentGrid.

getPool

public org.apache.commons.pool.ObjectPool getPool()
Getter for property pool.

Returns:
Value of property pool.

setPool

public void setPool(org.apache.commons.pool.ObjectPool pool)
Setter for property pool.

Parameters:
pool - New value of property pool.


Copyright © 2000-2003 Mark Robert Diggory. All Rights Reserved.