Class Sugarscape

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended byjava.applet.Applet
                  extended byjavax.swing.JApplet
                      extended bySugarscape
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.lang.Runnable, java.io.Serializable

public class Sugarscape
extends javax.swing.JApplet
implements java.lang.Runnable, java.awt.event.ActionListener

Built-on the original code from
--------------------------------
Game of Life v1.3
Copyright 1996-2001 Edwin Martin
version 1.0 online since July 3 1996
Changes:
1.1: Double buffering to screen; faster paint
1.2: Arrowkeys changed; better use of `synchronized'
1.3: Choose speed from drop down menu and draw with mouse

-------------Sugarscape - Linked List version------------
-------------abraham kannankeril---------------------------
1.4: Added template 'Random'& 'Big Bang' to layout choices
-------------------------xxx-------------------------------
2.0: Add Sugarscape & Citizen objects incorporating a new
& more sophisticated ruleset.
-> a single resource (sugar) is randomly dispersed on the grid (sugarscape)
-> citizens scattered on the sugarscape must collect & consume sugar to ensure survival
-> citizens possess attributes - vision, metabolism & sugar hoard
System-level variables can be manually adjusted via public constants to influence
behavior on the sugarscape.
2.1: Split into multiple files for better manageablity - package GameOfLife
Added system variable DEBUG to switch debug info ON/OFF
2.2: Added visual representation of cell & citizen properties
-> cells shaded to represent available sugar level (low / medium / high)
-> citizen shaded to represent available sugar level (low / medium / high)
-> citizen shape conveys representation of following combined properties
- high vision, high metabolism
- high vision, low metabolism
- low vision, high metabolism
- low vision, low metabolism
2.21 Improved sugar search routine to enable neutral selection between equally fertile cells
and selection of random cell if no sugar available to citizen
Added boolean variables to toggle debugging of selected program functions
Added boolean flag to allow imposition of limits on sugar accumulation in cells and a
corresponding method to depict absolute values of the sugar matrix
Color cues implemented in visual display:
-> Cell color darkens according to sugar accumulated in each cell
-> Citizen color gradually varies from red to orange to yellow to green to represent the amount of sugar collected
-> Citizen shape varies to depict one of four relative vision/metabolism combinations -> Grid coordinates can be printed if needed. This includes options to print all or some coordinates & to select a print color
2.22 All output from the program has now been redirected to a graphical textarea within the same window as the grid. The earlier dump into STDOUT has been discontinued.
2.30 Eliminated "Active Cell found unexpectedly" error
Eliminated grid sugar renewal problem - now regenerated with new sugarscape
Added debugging variable, DEBUG_PROGRAM_FLOW - enables tracing of method sequence
Added command line interface to enable interactive control of program parameters
2.35 Added mate selection, child birth and death by aging to the Citizen object.
The Citizen object now recognizes familial relationships (sibling, parent, child).
Reworked the debug feedback elements. The program feedback has a much smaller delay during execution.
Renamed main class/package to Sugarscape to reflect the true name of the project.
2.36 Added climate change, pollution
grid fertility adjustable by season
2.37 Unreleased version, implements the option
- to resize the grid at runtime.
- of timing the major events(gathering & mating).
- of executing a specified number timePeriods via the command-line.
- to inspect data values for any citizen on the grid and the entire population.
- to start/stop climate change & pollution.
-----------------------
2.40 Major design changes resulting from creation of new Cell object. -> The Cell object is now a subclass of the CellSpace object and a superclass of the Citizen object.
-> A seperate linked list of references to each citizen is maintained which simplifies operations involving all citizens, shuffling citizens randomly and locating occupants of a particular cell.
-> The major benefit of this redesign (suggested by Digvijay Parmar) is in performance.
The resulting code is atleast five times faster than my earlier design. -> That the code is cleaner & more readable is a welcome by-product.
-> I would also like to express my gratitude to Ms. Richa Parmar, whose expert advice, eliminated seemingly enormous obstacles for this novice programmer.
BEWARE - the ability to click or drag cells to create/destroy citizens has not been fully implemented, due to plain laziness :)
2.41 Added command 'DEMO' / 'TEST' to help demonstrate common program features.
-> Add 2nd commodity, SPICE to the Sugarscape. Citizens need both
-> Changed graphics to represent 2nd commodity & color-coded citizens based on type
-> Added variables in GoLconst to enable manipulation of new/modified objects
2.42 Add Barter process to the Sugarscape. -> Module incorporates internal evaluation, price negotiation and goods exchange.
-> Added 'persona' to citizen - determines Barter strategy. Either maximizing trades involving single units (risk-taker) or maximizing volume by selling multiple units in safe trades (risk-averse) strategies. Allows creation of additional strategies.
2.43 Added a tabbed-pane interface to replace the simple TextArea object that was previously used to display results. -> Separate panes now display simulation progress data, allow configuration and debugging. -> Forced to switch from AWT to Swing graphics libraries, applet therefore executes only in AppletViewer, working to improve the situation. -> Rectified error in barter processes that caused corruption of trade data. -> Added time counter for the barter processes. -> Moved GUI objects to seperate top-level mini-classes within Sugarscape.java to overcome problems hindering program execution as an applet. -----------------------------------xxx---------------------------------------- This is the primary class in the Sugarscape project. Its sub-components include the CellSpace or grid object, the Cell and Citizen objects.
Class Sugarscape sets up the GUI interface, the thread the executes the simulation, event handlers that control various Game of Life and Sugarscape templates and execute run-time commands.

Author:
abraham kannankeril
parts of code in this class borrowed with permission from Edwin Martin's Game of Life
See Also:
Sugarscape Home, The Book, NetLogo Implementation, Article on Sugarscape, Article on AI, eBook - Simulation for the Social Science, Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JApplet
javax.swing.JApplet.AccessibleJApplet
 
Nested classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  java.lang.String bigbang
           
 javax.swing.border.Border blackline
           
 javax.swing.JComboBox c
          Template Choice and speed control
 javax.swing.JTextField ce3D
           
 javax.swing.JTextField ceBar
           
 javax.swing.JTextField ceBground
           
 javax.swing.JTextField ceChild
           
 javax.swing.JTextField ceLimitSpice
           
 javax.swing.JTextField ceLimitSugar
           
private  int cellCols
           
 javax.swing.JPanel cellPanel
           
private  int cellRows
           
private  int cellSize
           
private  CellSpace cellSpace
          The only instance of a CellSpace object in the simulation.
 javax.swing.JTextField cePolluDispersal
           
 javax.swing.JTextField cePolluSpice
           
 javax.swing.JTextField cePolluSugar
           
 javax.swing.JTextField ceRenewSpSummer
           
 javax.swing.JTextField ceRenewSpWinter
           
 javax.swing.JTextField ceRenewSuSummer
           
 javax.swing.JTextField ceRenewSuWinter
           
 javax.swing.JTextField ceSenior
           
 javax.swing.JTextField ceSpiceMax
           
 javax.swing.JTextField ceSpiceMin
           
 javax.swing.JTextField ceSugarMax
           
 javax.swing.JTextField ceSugarMin
           
 javax.swing.JTextField ciInheritInitial
           
 javax.swing.JTextField ciKinMate
           
 javax.swing.JTextField ciLifeMax
           
 javax.swing.JTextField ciLifeMin
           
 javax.swing.JTextField ciMateFemaleGap
           
 javax.swing.JTextField ciMateFemaleMax
           
 javax.swing.JTextField ciMateFemaleMin
           
 javax.swing.JTextField ciMateMaleGap
           
 javax.swing.JTextField ciMateMaleMax
           
 javax.swing.JTextField ciMateMaleMin
           
 javax.swing.JTextField ciPersona
           
 javax.swing.JTextField ciSex
           
 javax.swing.JTextField ciSpicePoor
           
 javax.swing.JTextField ciSpMax
           
 javax.swing.JTextField ciSpMetab
           
 javax.swing.JTextField ciSpMin
           
 javax.swing.JTextField ciSugarPoor
           
 javax.swing.JTextField ciSuMax
           
 javax.swing.JTextField ciSuMetab
           
 javax.swing.JTextField ciSuMin
           
 javax.swing.JTextField ciSurnamesFather
           
 javax.swing.JTextField ciSurnamesUnique
           
 javax.swing.JPanel citizenPanel
           
 javax.swing.JTextField ciVision
           
private  java.lang.String clear
           
 javax.swing.JPanel configPanel
           
 javax.swing.JPanel controls
           
 javax.swing.JTextField deBarter
           
 javax.swing.JTextField deBarterExchange
           
 javax.swing.JTextField deBarterSort
           
 javax.swing.JTextField deChildBirth
           
 javax.swing.JTextField deCitizenBirth
           
 javax.swing.JTextField deCitizenDeath
           
 javax.swing.JTextField deCmdFeedback
           
 javax.swing.JTextField deCriticalError
           
 javax.swing.JTextField deDebug
           
 javax.swing.JTextField deInheritance
           
 javax.swing.JTextField deMateSearch
           
 javax.swing.JTextField deMateSelection
           
 javax.swing.JTextField deMating
           
 javax.swing.JTextField dePollution
           
 javax.swing.JTextField deProductionSpice
           
 javax.swing.JTextField deProductionSugar
           
 javax.swing.JTextField deProgFlow
           
 javax.swing.JTextField deSugarSearch
           
 javax.swing.JTextField deTime
           
 javax.swing.border.Border doubleBlack
           
private  java.lang.String exploder1
           
private  java.lang.String exploder2
           
private  java.lang.String fast
           
private  java.lang.String fish
           
private  java.lang.Thread gameThread
           
private  javax.swing.JLabel genLabel
           
private  int genTime
           
private  java.lang.String glider
           
private  java.lang.String gun
           
 javax.swing.JPanel historyPanel
           
private  java.lang.String hyper
           
 javax.swing.JButton nextButton
           
private  java.lang.String nextLabel
          Label for buttons
 javax.swing.border.Border paneEdge
           
private  java.lang.String pump
           
private  java.lang.String random
           
private  java.lang.String row10
           
 javax.swing.JTextField scAvgAge
           
 javax.swing.JTextField scAvgLifespan
           
 javax.swing.JTextField scAvgSpice
           
 javax.swing.JTextField scAvgSpMetab
           
 javax.swing.JTextField scAvgSugar
           
 javax.swing.JTextField scAvgSuMetab
           
 javax.swing.JTextField scAvgVision
           
 javax.swing.JTextField scBirths
           
 javax.swing.JTextField scDeaths
           
 javax.swing.JTextField scDensity
           
 javax.swing.JTextField scDistAdults
           
 javax.swing.JTextField scDistChildren
           
 javax.swing.JTextField scDistFemale
           
 javax.swing.JTextField scDistMale
           
 javax.swing.JTextField scDistSeniors
           
 javax.swing.JTextField scDistSummer
           
 javax.swing.JTextField scDistWinter
           
 javax.swing.JTextField scEff
           
 javax.swing.JTextField scHyp
           
 javax.swing.JTextField scHypSp
           
 javax.swing.JTextField scHypSu
           
 javax.swing.JTextField scInEff
           
 javax.swing.JTextField scOldAge
           
 javax.swing.JPanel scorePanel
           
 javax.swing.JTextField scPerCycle
           
 javax.swing.JTextField scProcGather
           
 javax.swing.JTextField scProcMate
           
 javax.swing.JTextField scProcMisc
           
 javax.swing.JTextField scProcTrade
           
 javax.swing.JTextField scRiskAverse
           
 javax.swing.JTextField scRiskTaker
           
 javax.swing.JTextField scSlow
           
 javax.swing.JTextField scSlowSp
           
 javax.swing.JTextField scSlowSu
           
 javax.swing.JTextField scStarved
           
private  java.lang.String slow
          Speed settings for the simulation
 javax.swing.JComboBox speed
          Template Choice and speed control
 javax.swing.JPanel sScapePanel
           
 javax.swing.JTextField ssCols
           
 javax.swing.JTextField ssCoordColor
           
 javax.swing.JTextField ssCoordDetail
           
 javax.swing.JTextField ssCoordShow
           
 javax.swing.JTextField ssCoordSize
           
 javax.swing.JTextField ssDensity
           
 javax.swing.JTextField ssFertSpice
           
 javax.swing.JTextField ssFertSugar
           
 javax.swing.JTextField ssMaxCols
           
 javax.swing.JTextField ssMaxRows
           
 javax.swing.JTextField ssPanelHeight
           
 javax.swing.JTextField ssPanelMax
           
 javax.swing.JTextField ssPanelMin
           
 javax.swing.JTextField ssProcGather
           
 javax.swing.JTextField ssProcInherit
           
 javax.swing.JTextField ssProcMate
           
 javax.swing.JTextField ssProcPollution
           
 javax.swing.JTextField ssProcSeasons
           
 javax.swing.JTextField ssProcTrade
           
 javax.swing.JTextField ssRows
           
 javax.swing.JTextField ssSeasonDuration
           
private  java.lang.String startLabel
           
 javax.swing.JButton startstopButton
           
private  java.lang.String stopLabel
           
private  java.lang.String sugarscape
           
 javax.swing.JTabbedPane tabPanel
           
private  javax.swing.JTextArea textArea
           
private  javax.swing.JTextField textField
           
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.applet.Applet
 
Fields inherited from class java.awt.Panel
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Sugarscape()
           
 
Method Summary
 void actionControls(java.lang.String arg)
          Implements various template options for the Game of Life (multiple) and the Sugarscape (one)
 void actionPerformed(java.awt.event.ActionEvent evt)
          This Method implements command-line control for the program.
 void createCellPanel()
           
 void createCitizenPanel()
           
 void createConfigPanel()
           
 void createScorePanel()
           
 javax.swing.JComboBox createSpeedList()
           
 void createSscapePanel()
           
 javax.swing.JComboBox createTemplateList()
           
 void drawRandomShape()
          Draws a random template on the Game of Life grid.
 void drawShape(int shapeWidth, int shapeHeight, int[] shape)
          Draws the shape to canvas depending on the template selected for all selections relating to the Game of Life.
Calls the relevant method in the CellSpace class.
 void drawSugarscape(int cellCols, int cellRows)
          Implements the Sugarscape template by calling the relevant method in the CellSpace class.
Provides the option to specify physical dimensions by passing parameters for columns and rows through HTML code.
static java.lang.String filler(int size)
           
 java.lang.String getAppletInfo()
          Program info accessible through the menu options of the Appletviewer
 void init()
          Initialises the GUI including the CellSpace object and starts the Sugarscape thread.
 void run()
          This method monitors status of the simulation and stops execution if the population dies out.
 void showGenerations()
          Show number of cycles that have executed and the current population count
 void start2()
          No start() to prevent starting immediately.
This method enables the GUI to initialize and await action from the user to begin execution, rather than executing as soon as the applet has finished loading.
 void stop()
          Pauses the current simulation
 void updateCellPanel()
           
 void updateCitizenPanel()
           
 void updateConfigPanel()
           
 void updateScorePanel()
           
 void updateSscapePanel()
           
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bigbang

private final java.lang.String bigbang
See Also:
Constant Field Values

blackline

public final javax.swing.border.Border blackline

c

public javax.swing.JComboBox c
Template Choice and speed control


ce3D

public javax.swing.JTextField ce3D

ceBar

public javax.swing.JTextField ceBar

ceBground

public javax.swing.JTextField ceBground

ceChild

public javax.swing.JTextField ceChild

ceLimitSpice

public javax.swing.JTextField ceLimitSpice

ceLimitSugar

public javax.swing.JTextField ceLimitSugar

cellCols

private int cellCols

cellPanel

public javax.swing.JPanel cellPanel

cellRows

private int cellRows

cellSize

private int cellSize

cellSpace

private CellSpace cellSpace
The only instance of a CellSpace object in the simulation.


cePolluDispersal

public javax.swing.JTextField cePolluDispersal

cePolluSpice

public javax.swing.JTextField cePolluSpice

cePolluSugar

public javax.swing.JTextField cePolluSugar

ceRenewSpSummer

public javax.swing.JTextField ceRenewSpSummer

ceRenewSpWinter

public javax.swing.JTextField ceRenewSpWinter

ceRenewSuSummer

public javax.swing.JTextField ceRenewSuSummer

ceRenewSuWinter

public javax.swing.JTextField ceRenewSuWinter

ceSenior

public javax.swing.JTextField ceSenior

ceSpiceMax

public javax.swing.JTextField ceSpiceMax

ceSpiceMin

public javax.swing.JTextField ceSpiceMin

ceSugarMax

public javax.swing.JTextField ceSugarMax

ceSugarMin

public javax.swing.JTextField ceSugarMin

ciInheritInitial

public javax.swing.JTextField ciInheritInitial

ciKinMate

public javax.swing.JTextField ciKinMate

ciLifeMax

public javax.swing.JTextField ciLifeMax

ciLifeMin

public javax.swing.JTextField ciLifeMin

ciMateFemaleGap

public javax.swing.JTextField ciMateFemaleGap

ciMateFemaleMax

public javax.swing.JTextField ciMateFemaleMax

ciMateFemaleMin

public javax.swing.JTextField ciMateFemaleMin

ciMateMaleGap

public javax.swing.JTextField ciMateMaleGap

ciMateMaleMax

public javax.swing.JTextField ciMateMaleMax

ciMateMaleMin

public javax.swing.JTextField ciMateMaleMin

ciPersona

public javax.swing.JTextField ciPersona

ciSex

public javax.swing.JTextField ciSex

ciSpicePoor

public javax.swing.JTextField ciSpicePoor

ciSpMax

public javax.swing.JTextField ciSpMax

ciSpMetab

public javax.swing.JTextField ciSpMetab

ciSpMin

public javax.swing.JTextField ciSpMin

ciSugarPoor

public javax.swing.JTextField ciSugarPoor

ciSuMax

public javax.swing.JTextField ciSuMax

ciSuMetab

public javax.swing.JTextField ciSuMetab

ciSuMin

public javax.swing.JTextField ciSuMin

ciSurnamesFather

public javax.swing.JTextField ciSurnamesFather

ciSurnamesUnique

public javax.swing.JTextField ciSurnamesUnique

citizenPanel

public javax.swing.JPanel citizenPanel

ciVision

public javax.swing.JTextField ciVision

clear

private final java.lang.String clear
See Also:
Constant Field Values

configPanel

public javax.swing.JPanel configPanel

controls

public javax.swing.JPanel controls

deBarter

public javax.swing.JTextField deBarter

deBarterExchange

public javax.swing.JTextField deBarterExchange

deBarterSort

public javax.swing.JTextField deBarterSort

deChildBirth

public javax.swing.JTextField deChildBirth

deCitizenBirth

public javax.swing.JTextField deCitizenBirth

deCitizenDeath

public javax.swing.JTextField deCitizenDeath

deCmdFeedback

public javax.swing.JTextField deCmdFeedback

deCriticalError

public javax.swing.JTextField deCriticalError

deDebug

public javax.swing.JTextField deDebug

deInheritance

public javax.swing.JTextField deInheritance

deMateSearch

public javax.swing.JTextField deMateSearch

deMateSelection

public javax.swing.JTextField deMateSelection

deMating

public javax.swing.JTextField deMating

dePollution

public javax.swing.JTextField dePollution

deProductionSpice

public javax.swing.JTextField deProductionSpice

deProductionSugar

public javax.swing.JTextField deProductionSugar

deProgFlow

public javax.swing.JTextField deProgFlow

deSugarSearch

public javax.swing.JTextField deSugarSearch

deTime

public javax.swing.JTextField deTime

doubleBlack

public final javax.swing.border.Border doubleBlack

exploder1

private final java.lang.String exploder1
See Also:
Constant Field Values

exploder2

private final java.lang.String exploder2
See Also:
Constant Field Values

fast

private final java.lang.String fast
See Also:
Constant Field Values

fish

private final java.lang.String fish
See Also:
Constant Field Values

gameThread

private java.lang.Thread gameThread

genLabel

private javax.swing.JLabel genLabel

genTime

private int genTime

glider

private final java.lang.String glider
See Also:
Constant Field Values

gun

private final java.lang.String gun
See Also:
Constant Field Values

historyPanel

public javax.swing.JPanel historyPanel

hyper

private final java.lang.String hyper
See Also:
Constant Field Values

nextButton

public javax.swing.JButton nextButton

nextLabel

private final java.lang.String nextLabel
Label for buttons

See Also:
Constant Field Values

paneEdge

public final javax.swing.border.Border paneEdge

pump

private final java.lang.String pump
See Also:
Constant Field Values

random

private final java.lang.String random
See Also:
Constant Field Values

row10

private final java.lang.String row10
See Also:
Constant Field Values

scAvgAge

public javax.swing.JTextField scAvgAge

scAvgLifespan

public javax.swing.JTextField scAvgLifespan

scAvgSpice

public javax.swing.JTextField scAvgSpice

scAvgSpMetab

public javax.swing.JTextField scAvgSpMetab

scAvgSugar

public javax.swing.JTextField scAvgSugar

scAvgSuMetab

public javax.swing.JTextField scAvgSuMetab

scAvgVision

public javax.swing.JTextField scAvgVision

scBirths

public javax.swing.JTextField scBirths

scDeaths

public javax.swing.JTextField scDeaths

scDensity

public javax.swing.JTextField scDensity

scDistAdults

public javax.swing.JTextField scDistAdults

scDistChildren

public javax.swing.JTextField scDistChildren

scDistFemale

public javax.swing.JTextField scDistFemale

scDistMale

public javax.swing.JTextField scDistMale

scDistSeniors

public javax.swing.JTextField scDistSeniors

scDistSummer

public javax.swing.JTextField scDistSummer

scDistWinter

public javax.swing.JTextField scDistWinter

scEff

public javax.swing.JTextField scEff

scHyp

public javax.swing.JTextField scHyp

scHypSp

public javax.swing.JTextField scHypSp

scHypSu

public javax.swing.JTextField scHypSu

scInEff

public javax.swing.JTextField scInEff

scOldAge

public javax.swing.JTextField scOldAge

scorePanel

public javax.swing.JPanel scorePanel

scPerCycle

public javax.swing.JTextField scPerCycle

scProcGather

public javax.swing.JTextField scProcGather

scProcMate

public javax.swing.JTextField scProcMate

scProcMisc

public javax.swing.JTextField scProcMisc

scProcTrade

public javax.swing.JTextField scProcTrade

scRiskAverse

public javax.swing.JTextField scRiskAverse

scRiskTaker

public javax.swing.JTextField scRiskTaker

scSlow

public javax.swing.JTextField scSlow

scSlowSp

public javax.swing.JTextField scSlowSp

scSlowSu

public javax.swing.JTextField scSlowSu

scStarved

public javax.swing.JTextField scStarved

slow

private final java.lang.String slow
Speed settings for the simulation

See Also:
Constant Field Values

speed

public javax.swing.JComboBox speed
Template Choice and speed control


sScapePanel

public javax.swing.JPanel sScapePanel

ssCols

public javax.swing.JTextField ssCols

ssCoordColor

public javax.swing.JTextField ssCoordColor

ssCoordDetail

public javax.swing.JTextField ssCoordDetail

ssCoordShow

public javax.swing.JTextField ssCoordShow

ssCoordSize

public javax.swing.JTextField ssCoordSize

ssDensity

public javax.swing.JTextField ssDensity

ssFertSpice

public javax.swing.JTextField ssFertSpice

ssFertSugar

public javax.swing.JTextField ssFertSugar

ssMaxCols

public javax.swing.JTextField ssMaxCols

ssMaxRows

public javax.swing.JTextField ssMaxRows

ssPanelHeight

public javax.swing.JTextField ssPanelHeight

ssPanelMax

public javax.swing.JTextField ssPanelMax

ssPanelMin

public javax.swing.JTextField ssPanelMin

ssProcGather

public javax.swing.JTextField ssProcGather

ssProcInherit

public javax.swing.JTextField ssProcInherit

ssProcMate

public javax.swing.JTextField ssProcMate

ssProcPollution

public javax.swing.JTextField ssProcPollution

ssProcSeasons

public javax.swing.JTextField ssProcSeasons

ssProcTrade

public javax.swing.JTextField ssProcTrade

ssRows

public javax.swing.JTextField ssRows

ssSeasonDuration

public javax.swing.JTextField ssSeasonDuration

startLabel

private final java.lang.String startLabel
See Also:
Constant Field Values

startstopButton

public javax.swing.JButton startstopButton

stopLabel

private final java.lang.String stopLabel
See Also:
Constant Field Values

sugarscape

private final java.lang.String sugarscape
See Also:
Constant Field Values

tabPanel

public javax.swing.JTabbedPane tabPanel

textArea

private javax.swing.JTextArea textArea

textField

private javax.swing.JTextField textField
Constructor Detail

Sugarscape

public Sugarscape()
Method Detail

actionControls

public void actionControls(java.lang.String arg)
Implements various template options for the Game of Life (multiple) and the Sugarscape (one)

Parameters:
arg -
Returns:
return boolean, always true

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
This Method implements command-line control for the program. It enables manipulation of program parameters that are otherwise only configurable in the GoLconst.java source file.
Accepts text commands in a textfield at the bottom of the Sugarscape GUI.
Users can type 'help' in this field for a reference list of commands.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
evt -

createCellPanel

public void createCellPanel()

createCitizenPanel

public void createCitizenPanel()

createConfigPanel

public void createConfigPanel()

createScorePanel

public void createScorePanel()

createSpeedList

public javax.swing.JComboBox createSpeedList()

createSscapePanel

public void createSscapePanel()

createTemplateList

public javax.swing.JComboBox createTemplateList()

drawRandomShape

public void drawRandomShape()
Draws a random template on the Game of Life grid. Calls the relevant method in the CellSpace class.


drawShape

public void drawShape(int shapeWidth,
                      int shapeHeight,
                      int[] shape)
Draws the shape to canvas depending on the template selected for all selections relating to the Game of Life.
Calls the relevant method in the CellSpace class.

Parameters:
shapeWidth - defines the max width of the requested template
shapeHeight - defines the max height of the requested template
shape - boolean array that defines exact shape to be drawn for a given template.

drawSugarscape

public void drawSugarscape(int cellCols,
                           int cellRows)
Implements the Sugarscape template by calling the relevant method in the CellSpace class.
Provides the option to specify physical dimensions by passing parameters for columns and rows through HTML code. This applies to webpages executing the program as an applet.

Parameters:
cellCols - number of columns passed as parameters by a parent webpage.
cellRows - number of rows passed as parameters by a parent webpage.
See Also:
CellSpace.CellSpace(int, int, int, JTextArea)

filler

public static java.lang.String filler(int size)

getAppletInfo

public java.lang.String getAppletInfo()
Program info accessible through the menu options of the Appletviewer

Returns:
program information - this information is displayed when the user types "INFO" at the command line of the Sugarscape.

init

public void init()
Initialises the GUI including the CellSpace object and starts the Sugarscape thread.


run

public void run()
This method monitors status of the simulation and stops execution if the population dies out. It continues the next cycle until interrupted by the user. It also controls the pace of execution of the simulation at one of three speeds

Specified by:
run in interface java.lang.Runnable

showGenerations

public void showGenerations()
Show number of cycles that have executed and the current population count


start2

public void start2()
No start() to prevent starting immediately.
This method enables the GUI to initialize and await action from the user to begin execution, rather than executing as soon as the applet has finished loading.


stop

public void stop()
Pauses the current simulation


updateCellPanel

public void updateCellPanel()

updateCitizenPanel

public void updateCitizenPanel()

updateConfigPanel

public void updateConfigPanel()

updateScorePanel

public void updateScorePanel()

updateSscapePanel

public void updateSscapePanel()