edu.brook.ascape.model
Class AscapeObject

java.lang.Object
  |
  +--edu.brook.ascape.model.AscapeObject
Direct Known Subclasses:
Agent, Rule

public class AscapeObject
extends java.lang.Object
implements HasName, java.lang.Cloneable, java.io.Serializable

The cannonical class for most ascape model objects, including rules. Used to manage basic features, such as access to random stream. Every ascape object should 'belong' to some scape, but is not neccesarily a member of that scape.

Since:
1.0.1
Version:
1.0.1
See Also:
Serialized Form

Field Summary
static int ARBITRARY_SEED
          Symbol for random seed to be arbitrary (current time in milliseconds.)
static int count
           
protected  java.lang.String name
          The name of this object
protected  Scape scape
          The agent that this object belongs to.
 
Constructor Summary
AscapeObject()
          Constructs an ascape object.
AscapeObject(java.lang.String name)
          Constructs an ascape object.
 
Method Summary
 java.lang.Object clone()
          Clones this object.
 java.lang.String getName()
          A name this object may be referred to by.
 java.util.Random getRandom()
          Gets the random number stream used by this object.
 long getRandomSeed()
          Returns the seed for the default random number seed.
 Scape getScape()
          Returns the scape that this object is primarily related to.
static double randomInRange(double low, double high)
          Returns an integer distributed across some range as the supplied integer is uniformally distributed across the full range of integers.
static int randomInRange(int low, int high)
          Returns an integer distributed across some range as the supplied integer is uniformally distributed across the full range of integers.
static boolean randomIs()
          Returns a random boolean value.
static int randomToLimit(int limit)
          Returns an integer distributed across 0...high - 1 as the supplied integer is distributed across the full range of integers.
 void reseed()
          Resets the random number generator.
 void setName(java.lang.String name)
          Sets a name this object may be referred to by.
 void setRandom(java.util.Random newRandom)
          Sets the random number stream to be used by this object.
 void setRandomSeed(long seed)
          Sets the seed for the default random number seed.
 void setScape(Scape scape)
          Sets the scape that this object is primarily related to.
 java.lang.String toString()
          A string representing this object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ARBITRARY_SEED

public static final int ARBITRARY_SEED
Symbol for random seed to be arbitrary (current time in milliseconds.)

scape

protected Scape scape
The agent that this object belongs to. Note that this object is not neccesarily a member of the scape.

name

protected java.lang.String name
The name of this object

count

public static int count
Constructor Detail

AscapeObject

public AscapeObject()
Constructs an ascape object.

AscapeObject

public AscapeObject(java.lang.String name)
Constructs an ascape object.
Parameters:
name - the name of this object
Method Detail

setScape

public void setScape(Scape scape)
Sets the scape that this object is primarily related to.
Parameters:
scape - the scape this agent is belongs to

getScape

public Scape getScape()
Returns the scape that this object is primarily related to.

getName

public java.lang.String getName()
A name this object may be referred to by.
Specified by:
getName in interface HasName

setName

public void setName(java.lang.String name)
Sets a name this object may be referred to by.

setRandom

public void setRandom(java.util.Random newRandom)
Sets the random number stream to be used by this object. For this base class, sets a static variable random that is available to all objects. May be overriden to set an instance random stream instead.
Parameters:
the - new random number stream to use
See Also:
#findRandom

getRandom

public java.util.Random getRandom()
Gets the random number stream used by this object. For this base class, this is a static variable random available to all objects. If you want to provide scapes or agents with their own randoms, override this method and be sure to use it instead of simply accessing the random variable.

getRandomSeed

public long getRandomSeed()
Returns the seed for the default random number seed. Will return actual seed (not the arbitrary seed symbol) if seed is set for arbitrary seed.

setRandomSeed

public void setRandomSeed(long seed)
Sets the seed for the default random number seed. Call or override to set the seed for any instance random streams. Set to ARBITRAY_SEED to have the system generate an arbitrary random seed (current time in milliseconds) at start.
Parameters:
seed - the random number seed to use

reseed

public void reseed()
Resets the random number generator. If a seed has been provided, returns the number generator to its orginal state, so that the last series of random numbers can be reproduced. If the random seed has not been set, sets the random number generator to some undetermined state (based on current system clock.)

randomInRange

public static final int randomInRange(int low,
                                      int high)
Returns an integer distributed across some range as the supplied integer is uniformally distributed across the full range of integers. Used for returning a random integer between two values.
Parameters:
low - the lowest number (inclusive) that the resulting int might be
high - the hignest number (inclusive) that the resulting int might be

randomInRange

public static final double randomInRange(double low,
                                         double high)
Returns an integer distributed across some range as the supplied integer is uniformally distributed across the full range of integers. Used for returning a random integer between two values.
Parameters:
low - the lowest number (inclusive) that the resulting int might be
high - the hignest number (inclusive) that the resulting int might be

randomToLimit

public static final int randomToLimit(int limit)
Returns an integer distributed across 0...high - 1 as the supplied integer is distributed across the full range of integers. Used for returning a random integer between two values.
Parameters:
limit - the maximum limit (exclusize) of the rusulting int

randomIs

public static final boolean randomIs()
Returns a random boolean value.

clone

public java.lang.Object clone()
Clones this object. Typically should be overridden to create a copy that is deep with respect to its internal state (for mutables), shares parent and 'context' data with the original, and clears any positional or relational state that might create a resulting illegal state in a parent or peer. For example, a cloned cell with a memory vector would copy the memory vector, retain the original's scape, and clear its coordinate data (because it is usually not legal for two cells to exists at the same coordinate.) Does not throw CloneNotSupportedException, since all ascape objects should support it. Note: This scheme may change when we develop deep copying of scapes.
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
A string representing this object.
Overrides:
toString in class java.lang.Object

(c) 1998-2000 The Brookings Insitution
Webpage