The Computational Beauty of Nature
Source code

zcs

run a zeroth level classifier system on a terrain

zcs -help
  or
zcs    [-specs  string]  [-steps  integer] [-seed integer]
       [-size integer]  [-sinit  double]  [-lrate  double]
       [-drate  double]  [-trate  double]  [-crate double]
       [-mrate double]  [-grate  double]  [-cover  double]
       [-wild double] [-avelen integer] [-inv] [-mag inte-
       ger] [-term string]

Adapts a zeroth level classifier system (ZCS) with the implicit bucket brigade algorithm and a genetic algorithm so that the ZCS can traverse a two-dimensional terrain, avoid obstacles, and find food. At the beginning of each step the ZCS is placed at a random location of its world. It interacts with its environment until it finds food, which yields a reward. The simulation then restarts with the ZCS placed at a new random location. The progress of the ZCS is continuously plotted, while the statistics on the time to find food are calculated and displayed. At the end of the simulation the classifiers that make up the final ZCS are saved to a log file.

Train a zeroth level classifier system (ZCS) to traverse a two-dimensional terrain, avoid obstacles, and find food with the implicit bucket brigade algorithm and a genetic algorithm. At the beginning of each step the ZCS is placed at a random location of it's world. It interacts with its environment until it finds food, which yields a reward. The simulation then restarts with the ZCS placed at a new random location. The progress of the ZCS is continuously plotted, while the statistics on the time to find food are calculated and displayed. At the end of the simulation the classifiers that make up the final ZCS are saved to a log file.

Miscellany

The file format for the specifications files must contain the width and height of the world followed by the details of the world in ASCII format, where '.' is an empty cell, 'O' is a rock, and 'F' represent food. See any of the examples in the 'data' subdirectory of this distribution for more details.

The log file, 'zcs.log', contains one line per classifier with the condition string, the action string, and the strength of the classifier. The classifiers are sorted so the the strongest classifiers are printed first.

The ASCII output of the program shows the most recent, windowed average and the total average for the number of steps needed to find food.

Hints

See the author's book, "The Computational Beauty of Nature," for more details.

Bugs

No sanity checks are performed to make sure that any of the options make sense.

Options

-specsWorld specification file.data/woods1.txt
-stepsNumber of simulated trials.5000
-seedRandom seed for initial state.0
-sizePopulation size.400
-sinitInitial classifier strength.20.0
-lrateBB learning rate.0.2
-drateBB discount rate.0.71
-trateTax rate for strength reduce.0.1
-crateGA crossover rate.0.5
-mrateGA mutation rate.0.002
-grateGA invocation rate.0.25
-coverCovering factor.0.5
-wildProbability of # in cover.0.33
-avelenLength of windowed average.50
-invInvert all colors?True
-magMagnification factor.10
-termHow to plot points.None

zcs.c on GitHub