Table of Contents

Module: ant ant.py

A sample implementation of a unique finite state automaton with agents.

The FSAs consist of ants, which are agents that move around on a two-dimensional automaton. Ants have a state, a location, and a direction. They also have two figures that determine how complex they are: the total number of possible states they can have, and the total number of colors that the ant can discern and manipulate; both of these figures must powers of two. Ants are deterministic creatures, whose behavior is deterministically determined by their genomes; these consists of three lookup tables, or genes: one for state, one for color, and one for action.

Here, color refers to the cellular states of the underlying automaton (which do not spontaneously change). The total number of colors that an ant can interact with acts as a bitmask, called the color mask, on the underlying cell state; if an ant only can interact with 8 colors, then it can only retrieve and change the lower 3 bits of the state of each cell it is located on. The ant's state is an internal designation that modifies its behavior; the state is an integer between 0 and N - 1, where N is the total number of states. The lookup tables, or genes, are each used by the current perceived color and state, and thus are two dimensional arrays.

Ants can also perform an action, which is one of the four possible behaviors: do nothing, turn left, turn right, or move forward (advance).

Each update, an ant will do the following:

  • retrieve the cellular state and turn it into a color according to its color mask;

  • use that color and the ant's current state to do lookups on each of the ant's genes to get its new state, new color, and action;

  • apply the new color to the current cell state (taking into account the color mask);

  • change to the new state;

  • and, finally, perform the specified action.

Imported modules   
import cage
import curses
import random
import sys
Functions   
main
  main 
main ( stdscr )

Classes   

Ant

An individual FSA in the system.

Automaton

The actual automaton class.

Gene

A single lookup table, mapping color and state to a value.

Genome

The encapsulation of the total number of states and colors, as

Map

A standard toroidal topology with no neighborhood.


Table of Contents

This document was automatically generated on Sat Jul 29 13:31:37 2006 by HappyDoc version 2.1