Oobj56
cell4x4
cell1x1b
cell2x2b
Oobj151
Oobj152
Oobj156
Home
Detailed Explanation of Main Processes/Events
WalkThru
Screen shots with explanations
Scre'nshots
Project Design Details
Design
Oobj59
Documents
Design - Overview
Overview
Design - Details
Details
Design - Change Log
Change Log
Design - Pseudocode
Pseudocode
Overview

1) Introduction
---------------
The study of the Social Sciences is a complex subject matter particularly because certain kinds of controlled experimentation are difficult to implement. Hypotheses regarding responses of individuals or groups of individuals to social events cannot be tested very easily. Thus curtailing efforts to establish sound causal relationships between individual behaviors on a microscopic level & resulting effects on society.

A second significant drawback of many approaches to modeling human society is that they tend to build their approach on a homogenous model of the individual. These attempts build a single model of a human being and then replicate it in large numbers to examine social behavior. Such an approach naturally sacrifices heterogeneity of the human actor in its models/scenarios.
Many models especially those involving game theory and many of the classical economic models, tend to study static worlds or worlds frozen at a particular point in time. Such snapshots ignore the dynamics of time & its influence on their models.

This project attempts/intends to apply computer-based modeling techniques to study human social phenomena including gathering, mating, procreation, seasonal migration, interaction with an environment, trade, propagation of disease, population dynamics and much more.
The broad aim here is to develop a computational approach that permits the study of diverse types of human activity from an evolutionary perspective. Utility for education & research also requires the ability to configure various parameters controlling the simulation.

The software attempts this by using an OOP approach that represents the components required (terrain, human beings, resources) as objects with defined properties and rules of behavior. These and many of the objectives have been partially achieved, but the need to add sophistication and complexity continue to spur the next round of development. This work centers around development of the Cell and Citizen objects and the Rulesets that govern their interaction. While the first two are typical OOP components, the Rulesets are analogus to algorithms that guide their actions and responses to other objects and the Cellspace environment.

The major challenge in any such endeavor is the design of the environment and the flexibility that such design provides the ultimate end-users. Life as we know it, is pretty complicated. Once we get beyond the relatively simple rules for survival, gathering, propagation etc., we encounter complexities like culture, group formation and personality development. Incorporating economic processes like trade and the development of diverse industry are also a formidable task to design and program in a simulation.

Some part of that problem has been simplified with the adoption of ideas laid out in the book described in section 3 of this page. The book is but a starting point, as the project progresses, I plan to incorporate all the ideas that I can lay my hands on and, stitch into one cohesive whole. I  have no idea on whether this may prove useful to someone, but it gives me great pleasure just to create it. If someone out there finds it useful, that's just icing.



Details
The broad aim of this project is to use a computer simulation to examine diverse spheres of human activity both in concert & in isolation. Such an approach is necessarily multi-disciplinary as it examines biological, economic, social & political processes of human activity. These models can be described as 'artificial societies' and it is hoped that fundamental social structures & group behaviors emerge from individual-level rules and decisions.
This model involves three basic ingredients: human agents, a terrain with and on which they interact and micro-level rulesets that constrain their behavior. Agents are the citizens of artificial societies. They possess certain attributes and follow certain behavioral rules.   Some attributes like vision and metabolism are fixed for life while others like wealth & cultural identity change as the agents move and interact on the terrain.
The terrain is modeled as a two-dimensional grid of resource sites containing two or more resources. The land can be modeled as a complex entity in its own with varying levels of resource fertility, accumulating pollution, navigability (hilly terrain, more difficult to navigate than plateaus) etc. It can also be modeled to simulate a two-part terrain. Varying distributions of a land & water mass, each with its own properties and its own influence on the other can then be created. The final component of our AI model are agent are rulesets. A simple illustration of an agent rule can be described thus:
        Look around & find the richest source of sugar, go there and harvest it.


IMPLEMENTATION
The nature and complexities of agent-based AI simulations require the ability to
        - design an initial system,
        - write the code that executes the design,
        - redesign component modules, implement the redesign &
                integrate with the bigger system
This process of repeated refinement of the model leads to the automatic selection of object-oriented programming as the most suitable programming framework to use. Objects are highly independent self-contained components that include both data and procedures. This enables both the agent and the environment to be implemented as independent components. Changes can me made to one without having to rewrite the other.

The Sugarscape (terrain) is a two-dimensional grid of adjustable dimensions. The Sugarscape can be said to comprise of rows or columns of cells that represent the lowest unit of location on the Sugarscape. This just means that a citizen has to occupy all of one cell, there can be no sharing of cells. Think of this as a design limitation for now. The Sugarscape like the land masses it represents has boundaries and citizens are for the present hemmed in by these boundaries.

Cells have the following attributes: sugar, spice & pollution. Sugar and spice are harvested by citizens visiting the cell. Both are renewable resources and once harvested grow back at a pace determined by the executor of the simulation. The visual representation depicts the amount of sugar and spice available in cells as horizontal bars attached to two ends of the cell. The thickness of the bars serve as approximations of the amount of each resource. Cells may also be barren of one or both resource growing capability. This property is randomly determined during creation of the cells. The percentage of barren cells are determined by the user and can be set/changed at the start of each run of the simulation.

The citizen is the occupant of the Sugarscape, rather of individual cells on it. The Sugarscape typically hosts a number of citizens whose initial density on the grid is determined by the user. Each citizen possesses the following properties:
        - id,                unique descriptor identifying the citizen.
        - family,        shared name identifying either paternal or maternal lineage.
        - parents,        male & female citizens, whose mating resulted and who passed
                        on a mix of their attributes to their offspring. The first
                        generation of citizens lack parents.
        - birthYear        marking the start of their lifecycle on the Sugarscape.
        - location        specifies their current address on the Sugarscape.
        - inheritance        the initial allocation of sugar and spice received from their
                        parents
        - sugar        the total hoard of sugar available for consumption - is
                        determined as the sum of a citizen's inheritance and the net
                        sugar gathered, consumed & traded while roaming the
                        landscape.

CURRENT FEATURES
  • The major features incorporated into the software include:
  • implementation of the Game Of Life as described by Robert Conway with the facility to create initial templates.
  • development of the Sugarscape object (the land environment) that will play host to the human beings populating it.
  • the Citizen object representing the nature & properties of human beings.
  • a constants file that enables default seeding values for the various aspects of simulations that a researcher seeks to manipulate.
  • the graphical display that brings these elements together & depicts their interaction in real-time.
  • the ability to toggle feedback for specific sections of the code rather than inundating users with overwhelming feedback from all processes occurring on the Sugarscape.
  • a tabbed-pane interface for controlling the simulation and toggling the values of variables during runtime.
  • implementation of foraging & consumption activities involving two resources, sugar & spice.
  • implementation of mating & procreation. This includes sexual differentiation, recognition of familial ties, passage of physical characteristics from parents to children and inheritance.
  • the depiction of a life cycle that incorporates birth, puberty, menopause/andropause and finally, death.
  • implementation of internal valuation of the worth of each resource by citizens, seeking, evaluating and selecting trading partners and carrying out a mutually profitable exchange.

FEATURES TODO
The project objective is to continuously increase the level of sophistication of the various actors in the environment, especially the Citizen object. Features planned:
  • introduction of culture & conflict
  • disease & natural catastrophes
Additionally we intend to incorporate startup templates & historical snapshots to be generated & stored in some appropriate file format to enable exchange of results among interested observers.

A website showcasing the software & providing interaction to interested participants is available at http://sugarscape.sourceforge.net/.
Obtaining & reading a copy of "Growing Artificial Societies - Social Science From The Bottoms Up" by J Epstein & R Axtell is recommended. The book also comes with a CD that includes an implementation of a similar model. The code however does not seem to be Open Source and I have never seen or used it. I am in no way associated with the authors or publishers of this book.



Change Log
Built-on the original code from
Game of Life v1.3
Copyright 1996-2001 Edwin Martin <edwin@bitstorm.nl>
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

Start of Sugarscape - Linked List version
by 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
  • 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 following options:
  • 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 container of the Citizen object.
A separate 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 at least 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.
Added 2nd commodity, SPICE to the Sugarscape. Citizens need both to survive
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 (bull) or minimizing surplus by selling multiple units in safe trades (bear) 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 top-level mini-classes within Sugarscape.java to overcome problems hindering program execution as an applet.



Pseudocode
The purpose of describing the logic of the main sections of the sugarscape is two-fold. The obvious is to expose the algorithms to garner feedback, criticisms and suggestions from other developers. Secondly, the English-like language will hopefully evoke interest from an additional group of non-programmers among the Social Science  research community.
/* The drawSugarscape function or method is executed everytime the simulation is started for the first time.
This method receives two parameters denoting the number of columns and rows.
*/
if current grid size not equal to parameter gridsize
{
        set new grid size;
        resize grid to reflect new size;
}
clear grid of previous elements;
initialize totals for scoreboard;

if seasons process active
        grow resources by respective seasonal rate;
else        grow resources uniformly by summer rate;

for each cell in the grid
{
        generate random number;
        if random number < DENSITY Factor
        {
                create citizens with random attributes;
                gather resources in cell of birth;
                increment totals for sugar, spice, citizens
                         and births;
                add new citizen to list of citizens;
        }
}

/* nextScape is the routine/method executing each cycle of the simulation
*/
increment cycle count;
if season process active
        grow resources by respective seasonal rate;
else        grow resources uniformly by summer rate;

initialize totals & distribution for Scoreboard;
shuffle citizen list randomly;

while not all citizens processed
{        #START
        get next citizen on list;
        if end of lifespan has arrived
        {
                set "old age" as cause of death;
                add to dead citizen list;
                decrease population & increment death count;
                remove citizen from grid;
                go back to #START;
        }
        if not enough sugar or spice to eat
        {
                set "starvation" as cause of death;
                add to dead citizen list;
                decrease population & increment death count;
                remove citizen from grid;
                go back to #START;
        }
        search within range of citizen vision for resources;
        if search for goods unsuccessful
                randomly pick an empty but distant location;

        if empty cell, with or without resources found
                move to that cell and gather available resources;

        record gather time;

        if citizen of mating age & has sufficient surplus &
                has atleast one empty cell & prospective mates
        {
                prepare list of qualified prospective mates;
                if more than one mate
                {
                        shuffle mates in list;
                        pick one mate randomly but weighted by ranking;
                }
                bear child with attributes from citizen or mate;
                add child to newborn list;
                update ranking of citizen & mate to reflect transferred
                                        resources;
        }

        record mating time;

        if barter process active
                seek partners & trade;

        record barter time;
        tabulate Scoreboard totals and distributions for this citizen;
}

eliminate citizens on dead list from citizen list;
add children on newborn list to citizen list;
clear dead & newborn list;
disperse pollution;
record miscellaneous time;