Introduction
This article outlines the fundamental process.
As a simple outline, all of the program is in one single file. There are various main() functions for test modes (don't worry about them right now) but the actual main() requires -DRUN_MODE compile flag. This function does the following:
-
Set up a new cellular grid.
-
Iterate a fixed number of cycles.
-
Pick pairs of nearby cells.
-
Evaluate an interaction between pairs.
-
Save frames as PNM images every so often.
That's about the heart of it.
Quickstart to GA Internals
-
struct cell_S contains the data held in each cell.
-
function point_select() picks a random pair of nearby cells.
-
function hamming32() calculates Hamming distance.
-
function tolfunc() calculates the parametric tolerance (based on Hamming distance).
-
function outcome() calculates the outcome of the Prisoner's Dilemma.
-
function transaction() is the full interaction between the cells.
Quickstart to GA Internals
-
struct col_item_S contains a single item mapping from Hamming space to RGB colour space.
-
array col_item_T col_items[] is a list of standard colours and bitmaps.
-
function get_colour() converts from Hamming space to RGB colour space (using col_items).
-
function output_frame() dumps the whole cell grid to an image file (with colour translation, etc).