An Agent-Based Artificial Society

Site maintained by: Andrew Schlei
Last updated: 22 June 2003

Table of Contents:

Agent-Based Computational Economics (ACE) Website
ACE/CAS Interactive Computer Demos Site
Hunters Screen Shot

Introduction to Hunters [top]
Hunters is an agent-based artificial society model targeted for the Microsoft desktop. A population of hunter/gatherer agents, called hunters, must secure food in order to survive. The Hunter agents can do this by gathering food from the world around them, or by interacting with other agents.

Hunters have several options when it comes to interacting with each other. The first option is simply to attack other agents and attempt to steal food from them. If they manage to defeat their opponents, a hunter stands a lot to gain by interacting with others in this way. The second option for interaction is sharing. When agents share, they pool their resources so that both agents have food. While this may not always be profitable for an individual agent, it can be very good for the society as a whole. The third option for interaction is hoarding. When agents hoard, they essentially ignore other agents and just concentrate on holding onto whatever food they have.

All of the action takes place in a two-dimensional world of grid cells. Each grid cell can contain food, an agent, or possibly nothing at all. Each cell can only contain one item at a time, and every item takes up exactly one cell. Agents can move about the world, but cannot move into occupied squares and are not allowed to walk off the edge of the world.

The behavior of the Hunter agents is governed by two factors: individual learning; and evolution. Individual hunters adjust their action strategies throughout their lifetime. They adjust their strategies mainly by judging how successful their actions were in the past. The second factor, evolution, comes into play when agents die. Agents die when they run out of food, and end up being replaced by the offspring of more successful agents.

During each round of the simulation, every hunter agent gets a chance to move, gather food, and interact with other agents. Rounds continue until the end of a generation is reached. At this point, dead agents are replaced and a whole new generation begins. The entire simulation runs for a set number of generations, unless the entire population becomes extinct before that point is reached.

The purpose of this program is to allow for the study of agent behavior in artificial societies. The user has the ability to adjust a wide range of factors that might influence the outcome of the simulation. The program allows users to view the simulation in action, via a text-based display. The program also creates two output files to assist in this study, one for overall demographics, and one that logs agent interactions. This allows users to study how various factors influence the society.

Hunters Software Description [top]
The Hunters software was developed to simulate the artificial society in a text-based envirnonment. The program allows users to customize many parameters, which enables the users to adjust the program to their needs and carry out a wide range of experiments. The parameters are:
  • The X dimension of the world: This number must be a positive integer not greater than 75.
  • The Y dimension of the world: This number must be a positive integer not greater than 22.
  • The number of Hunter agents: This number must be a positive integer not greater than the number of cells in the world (X times Y).
  • The number of food cells available to each generation: This number must be a nonnegative integer not greater than the number of cells in the world (X times Y) minus the number of Hunter agents.
  • The value of each food cell: This number must be a nonnegative integer.
  • The amount of food each hunter starts with: This number must be a nonnegative integer.
  • The amount of food each hunter must consume each round: This number must be a nonnegative integer.
  • The material cost that all agents must pay when attacking: This number, in units of food, must be a nonnegative integer.
  • The utility offsets for attacking, sharing, and hoarding: These numbers can be arbitrary integers.
  • The range of vision for the hunters: This number must be a nonnegative integer.
  • The maximum power an agent can have: This number must be a nonnegative integer. The larger the maximum power, the more spread out the power ratings will tend to be. If maximum power is set to 0, all agents will have 0 power.
  • The number of generations to run: This number must be a a nonnegative integer.
  • The number of rounds in each generation: This number must be a nonnegative integer.
  • The sleep delay: This number, in milliseconds, must be a nonnegative integer. In general, the higher the sleep delay, the slower the simulation will run.

After all of the parameters have been entered, the simulation can begin. Users can watch the simulation via a text-based display. This visual representation of the world shows the entire world, plus all of the hunters in it that are currently alive. Each agent is displayed according to its position and its current strategy. The display is updated at the end of each round. The following symbols are used in the display:

  • "A": Represents agents that are attacking.
  • "S": Represents agents that are sharing.
  • "H": Represents agents that are hoarding.
  • "+": Represents grid squares that conatain food.

After the simulation has finished, the user can find output information in two files:

  • gen_output.dat This file contains general demographic information for each generation, including the number of agents employing each stategy at the beginning and end of the generation, the number of agents that survived for each strategy, the average power of agents employing each stategy, the overall average power rating, and the total survival rate.
  • log_output.dat This file contains a log of all of the interactions that took place during the simulation. Users should note that this log file will become extremely large if the simulation runs for a long time.

Hunters Download and Installation [top]
To download the Hunters installation files in a zip file (,834K), click here. To install the program, unzip the files into a folder and run the file called Setup.exe. Follow the steps to install the program.

Hunters Source Code and Implementation Info [top]
IMPLEMENTATION: The Hunters program was written using Visual C++ in Microsoft Visual Studio 6.0. Hunters consists of three source code files: "Hunters.cpp" (main driver program), "Hunter.h" (header file for Hunter class), and "Hunter.cpp" (implementation file for Hunter class).

You can download a zip file (,13K) containing the source code by clicking here.

ALGORITHM AND INNER WORKINGS: The basic algorithm that Hunters runs is as follows:

  • Create and initialize variables, allocate memory, and seed the pseudo-random number generator using the system time.
  • Get simulation parameters from the user.
  • Create the array that will serve as the the two dimensional world.
  • Create the array of Hunters and initialize the data for each agent.
  • Open the two output file streams.
  • For each generation:
    • Set up the world and the hunter agents. Place all agents and food cells randomly.
    • For each round:
      • Initialize hunter interaction arrays.
      • Each hunter moves and gathers food from its new location.
      • Each hunter interacts with any nearby agents that it has not interacted with already this round.
      • Each hunter consumes food and is declared dead if they have no food left.
      • Display the current state of the world to the screen.
    • Replace dead agents with the offspring of living agents by running Hunter evolution.

An html file (HunterIm.htm,13K) providing a more detailed description of the implementation, including the classes, variables, methods, rules, etc., can be viewed by clicking here.

Copyright Information [top]
The Hunters demo is licensed as open source freeware under the GNU Public License. Copyright Andrew Schlei, 2003. Anybody who is interested is allowed to view, modify, and/or improve upon the code used to produce this demo, but any software generated using all or part of this code must be released as open source freeware as well. To view the software license in its entirety, go here.

Feedback [top]
You can contact me at I would greatly appreciate your comments and suggestions.

Copyright 2003 Andrew Schlei. All Rights Reserved.