|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Sugarscape.Citizen
The Citizen object is modeled on a human being. It possesses attributes like
location, vision, metabolism rates, resource stockpiles, parents, sex etc.
Each Citizen lives a randomly determined lifespan during which they gather
& eat food, seek & select mates, bear children, trade to increase their wealth,
inherit wealth upon the death of parents etc.
As the simulation is developed further, these citizens become more capable and
are able to partake in more complex tasks. They function absolutely at a local level
and are unaware of external influences beyond their immediate surroundings.
Collectively however I hope their actions add to our understanding of how communal
behavior, that cannot be explained solely from individual actions, emerges.
Field Summary | |
(package private) int |
birthYear
|
(package private) java.lang.String |
causeOfDeath
|
(package private) java.util.List |
childList
|
(package private) static int |
citizenID
|
(package private) java.lang.String |
cultureTag
|
(package private) java.lang.String |
family
|
(package private) int |
father
|
(package private) static int |
HIGH_ENDOWMENT_SPICE
|
(package private) static int |
HIGH_ENDOWMENT_SUGAR
|
(package private) int |
homeCol
|
(package private) int |
homeRow
|
(package private) int |
id
|
(package private) float |
inheritSpice
|
(package private) float |
inheritSugar
|
(package private) int |
lastMating
|
(package private) int |
lifeSpan
|
(package private) int |
metabSpice
|
(package private) int |
metabSugar
|
(package private) int |
mother
|
(package private) float |
MRS
|
(package private) int |
persona
|
(package private) int |
ranking
|
(package private) int |
sex
|
(package private) float |
spice
|
(package private) int |
spUnits
|
(package private) float |
sugar
|
(package private) static java.util.List |
surnames
|
(package private) int |
surplus
|
(package private) int |
suUnits
|
(package private) int |
TUD
|
(package private) int |
vision
|
Constructor Summary | |
Citizen()
Base constructor for the Citizen object. |
|
Citizen(Citizen citizen,
Citizen mate,
int col,
int row)
Constructor used to create citizen object inheriting attributes from a pair of parent Citizen objects. |
|
Citizen(int col,
int row)
Constructor used to create new citizen object inside a cell object. |
Method Summary | |
int |
addChild(Citizen child)
Adds citizen to child list. |
int |
checkChildren()
Returns count of children in the child list. |
private int |
createFamilyNameList()
The following collections is randomly assigned to the initial inhabitants. |
static java.lang.String |
customFormat(java.lang.String pattern,
double value)
Method to format float and double vars for display on screen. |
boolean |
eatSpice()
Subtracts one consumption unit (spice metabolism) from the spice stockpile. |
boolean |
eatSugar()
Subtracts one consumption unit (sugar metabolism) from the sugar stockpile. |
int |
getAge()
Returns the age, defined as the birth year subtracted from the current cycle or time period. |
int |
getBirthYear()
Returns the cycle or time period when the citizen was born. |
java.lang.String |
getCauseOfDeath()
Returns a string describing the citizen's cause of death. |
int |
getCol()
Returns the column on the grid where the citizen is located. |
java.lang.String |
getFamily()
Returns a string identifying the citizen's family. |
int |
getFather()
Returns a numeric code uniquely identifying the citizen's father. |
int |
getID()
Returns a unique identification number for the citizen. |
float |
getInheritSpice()
Returns the spice inherited by the citizen from its parents. |
float |
getInheritSugar()
Returns the sugar inherited by the citizen from its parents. |
int |
getLastMating()
The cycle or time period when the citizen last mated successfully. |
int |
getLifeSpan()
Returns the expected lifespan of the citizen. |
int |
getMetabSpice()
Returns the value representing the citizen's metabolic rate for spice. |
int |
getMetabSugar()
Returns the value representing the citizen's metabolic rate for sugar. |
int |
getMother()
Returns a numeric code uniquely identifying the citizen's mother. |
float |
getMRS()
Calculated value. |
Citizen |
getNextChild(int childIndex)
Returns next child on list, null if no more children. |
int |
getPersona()
|
int |
getRanking()
Returns the ranking previously calculated for the citizen. |
int |
getRow()
Returns the row on the grid where the citizen is located. |
float |
getSpice()
Returns the value representing the citizen's spice stockpile. |
int |
getSpUnits()
Calculated value, depicting the number of units of spice available to the citizen. |
float |
getSugar()
Returns the value representing the citizen's sugar stockpile. |
int |
getSurplus()
Returns the surplus available for trade. |
int |
getSuUnits()
Calculated value, depicting the number of units of sugar available to the citizen. |
int |
getTUD()
Returns an estimated Time Until Death. |
int |
getVision()
Returns the value representing the vision of the citizen. |
boolean |
hasSurplus()
Returns true if the citizen has enough sugar to support prospective offspring. |
boolean |
isAlive()
Returns true if the citizen is still within the lifespan determined at birth. |
boolean |
isCautious()
Returns true, if the personality type for the citizen is risk-averse OR below the poverty level as defined by GoLconst.SUGAR_LEVEL_POOR and GoLconst.SPICE_LEVEL_POOR |
boolean |
isChild()
Returns true if the citizen's age falls within the range that defines childhood. |
boolean |
isChildOf(Citizen zenB)
Returns true if citizen is a child of the citizen passed as a parameter to this method.. |
boolean |
isKinOf(Citizen zenB)
Returns true if citizen is related to the citizen passed as a parameter to this method. |
boolean |
isMale()
Returns true if the citizen is of the 'male' sex. |
boolean |
isParentOf(Citizen zenB)
Returns true if citizen is a parent of the citizen passed as a parameter to this method. |
boolean |
isPoor()
Returns true if sugar or spice consumption units are less than or equal to wealth levels specified in the global constants (GoLconst.java) file. |
boolean |
isSenior()
Returns true if the citizen's age falls within the range that defines senior citizens. |
boolean |
isSiblingOf(Citizen zenB)
Returns true if two citizens share both parents. |
boolean |
needsSpice()
Returns true when citizen is 'Risk-Averse' and MRS < 1. |
boolean |
needsSugar()
Returns true when citizen is 'Risk-Averse' and MRS > 1. |
boolean |
ofCompatibleSex(Citizen zenB)
Returns true if the two prospective mates belong to the opposite sex. |
boolean |
ofMatingAge()
Returns true if the citizen's age falls between the range of values signifying childhood and old age. |
void |
paintZen(java.awt.Graphics g,
int cellSize)
Paints the citizen in to one of eight possible shapes The classification comprises eight categories and are representedgraphically as icons drawn using a combination of ovals and rectangles. |
boolean |
pastMatingInterval()
Returns true if the period specified in the global constants file has passed since the last successful mating for the citizen. |
static boolean |
preferSame(float MRSA,
float MRSB)
Returns true if two MRS values supplied as parameters have a preference for the same good. |
boolean |
prefersSpice()
Returns true when MRS < 1. |
boolean |
prefersSugar()
Returns true when MRS > 1. |
static void |
resetID()
Resets the variable that is used to generating unique ID's for each new citizen. |
void |
setCauseOfDeath(java.lang.String cause)
Stores the string describing cause of death in citizen. |
void |
setCol(int col)
Stores the column representing a current or designated location within the citizen object. |
private void |
setFamily()
|
private void |
setFamily(Citizen citizen,
Citizen mate)
|
static int |
setID()
Returns a unique numeric ID and increments it in preparation for the next request. |
private void |
setInheritAttributes(Citizen citizen,
Citizen mate)
Randomly choses newborn child's genetic attributes from one or the other parent. |
void |
setLastMating(int generation)
Updates last mating of citizen to current cycle or time period. |
void |
setLifeSpan(int ageVal)
Sets citizen lifespan to a specified or random value. |
int |
setMetabSpice(int metabolismVal)
Sets citizen spice metabolism to a specified or random value. |
int |
setMetabSugar(int metabolismVal)
Sets citizen sugar metabolism to a specified or random value. |
float |
setMRS()
Calculates value. |
private void |
setParents(Citizen citizen,
Citizen mate)
|
int |
setPersona()
Sets citizen vision to a random value. |
int |
setRanking()
Recalculates ranking for citizen. |
void |
setRow(int row)
Stores the row representing a current or designated location within the citizen object. |
int |
setSex()
Sets citizen sex to a specified or random value. |
float |
setSpice(float spiceVal)
Sets citizen spice to a specified or random value. |
int |
setSpUnits()
Calculates value, depicting the number of units of spice available to the citizen. |
float |
setSugar(float sugarVal)
Sets citizen sugar to a specified or random value. |
int |
setSurplus()
Calculates and returns the surplus available for trade. |
int |
setSuUnits()
Calculates value, depicting the number of units of sugar available to the citizen. |
int |
setTUD()
Calculates and returns an estimated Time Until Death. |
int |
setVision(int visionVal)
Sets citizen vision to a specified or random value. |
java.lang.String |
showStats(java.lang.String message)
Returns a string describing some of the key attributes for the citizen. |
private void |
transferWealth(Citizen citizen,
Citizen mate)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
int birthYear
java.lang.String causeOfDeath
java.util.List childList
static int citizenID
java.lang.String cultureTag
java.lang.String family
int father
static int HIGH_ENDOWMENT_SPICE
static int HIGH_ENDOWMENT_SUGAR
int homeCol
int homeRow
int id
float inheritSpice
float inheritSugar
int lastMating
int lifeSpan
int metabSpice
int metabSugar
int mother
float MRS
int persona
int ranking
int sex
float spice
int spUnits
float sugar
static java.util.List surnames
int surplus
int suUnits
int TUD
int vision
Constructor Detail |
public Citizen()
public Citizen(Citizen citizen, Citizen mate, int col, int row)
citizen
- parent of newborn citizen.mate
- parent of newborn citizen.col
- column identifying cell where citizen is to be created.row
- row identifying cell where citizen is to be created.public Citizen(int col, int row)
col
- column identifying cell where citizen is to be created.row
- row identifying cell where citizen is to be created.Method Detail |
public int addChild(Citizen child)
child
- newborn to be added to list of children born in current cycle.public int checkChildren()
private int createFamilyNameList()
GoLconst.CREATE_UNIQUE_SURNAMES
public static java.lang.String customFormat(java.lang.String pattern, double value)
pattern
- format pattern.value
- float/double value to format.
public boolean eatSpice()
public boolean eatSugar()
public int getAge()
public int getBirthYear()
public java.lang.String getCauseOfDeath()
public int getCol()
public java.lang.String getFamily()
public int getFather()
public int getID()
public float getInheritSpice()
public float getInheritSugar()
public int getLastMating()
public int getLifeSpan()
public int getMetabSpice()
public int getMetabSugar()
public int getMother()
public float getMRS()
public Citizen getNextChild(int childIndex)
childIndex
- index pointing to a specific child in the child list.public int getPersona()
public int getRanking()
public int getRow()
public float getSpice()
public int getSpUnits()
public float getSugar()
public int getSurplus()
public int getSuUnits()
public int getTUD()
public int getVision()
public boolean hasSurplus()
public boolean isAlive()
public boolean isCautious()
SUGAR_LEVEL_POOR
,
SPICE_LEVEL_POOR
public boolean isChild()
public boolean isChildOf(Citizen zenB)
zenB
- other citizen whose relation is being examined.public boolean isKinOf(Citizen zenB)
zenB
- other citizen whose relation is being examined.public boolean isMale()
public boolean isParentOf(Citizen zenB)
zenB
- other citizen whose relation is being examined.public boolean isPoor()
SUGAR_LEVEL_POOR
,
SPICE_LEVEL_POOR
public boolean isSenior()
public boolean isSiblingOf(Citizen zenB)
zenB
- other citizen whose relation is being examined.public boolean needsSpice()
public boolean needsSugar()
public boolean ofCompatibleSex(Citizen zenB)
zenB
- other citizen whose relation is being examined.public boolean ofMatingAge()
public void paintZen(java.awt.Graphics g, int cellSize)
g
- the handle to the graphics object that provides access to all
drawing methods.cellSize
- current cell sizepublic boolean pastMatingInterval()
public static boolean preferSame(float MRSA, float MRSB)
MRSA
- Marginal Rate of Substitution of spice to sugar for CitizenMRSB
- Marginal Rate of Substitution of spice to sugar for Trader.public boolean prefersSpice()
public boolean prefersSugar()
public static void resetID()
public void setCauseOfDeath(java.lang.String cause)
cause
- String explaining cause of death.public void setCol(int col)
col
- column identifying cell where citizen is currently located.private void setFamily()
private void setFamily(Citizen citizen, Citizen mate)
public static int setID()
private void setInheritAttributes(Citizen citizen, Citizen mate)
citizen
- parent #1public void setLastMating(int generation)
generation
- current time period.public void setLifeSpan(int ageVal)
ageVal
- public int setMetabSpice(int metabolismVal)
metabolismVal
- spice metabolism of citizenpublic int setMetabSugar(int metabolismVal)
metabolismVal
- sugar metabolism of citizenpublic float setMRS()
private void setParents(Citizen citizen, Citizen mate)
public int setPersona()
public int setRanking()
public void setRow(int row)
row
- row identifying cell where citizen is currently located.public int setSex()
public float setSpice(float spiceVal)
spiceVal
- value indicating how spice stockpile of citizen is to change.public int setSpUnits()
public float setSugar(float sugarVal)
sugarVal
- value indicating how sugar stockpile of citizen is to change.public int setSurplus()
public int setSuUnits()
public int setTUD()
public int setVision(int visionVal)
visionVal
- citizen visionpublic java.lang.String showStats(java.lang.String message)
message
- String to precede display of important citizen stats.private void transferWealth(Citizen citizen, Citizen mate)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |