Genetic Algorithm Code Walkthrough
The following diagram gives a basic process flow for how this simulation operates. None of it should be particularly surprising. After the diagram are some brief notes on each stage (and link to where the concepts are explained in more detail).
The cellular grid is merely a place to store a statistically significantly large number of individuals, and also a topology that only allows individuals to interact with relativly near neighbours. This is important, because when an individual reproduces, at least initially the individual is often interacting with a clone of itself (since reproduction always happens into a nearby location).
Each iteration picks a random cell, and then picks a random neighbour somewhere near that cell. The grid wraps left-to-right but not top-to-bottom (only because that was the easiest implementation).
The function responsible for this is the following:
void point_select( cell_T **Ap, cell_T **Bp )
The first part of the trust evaluation is a matter of what could be known about the other party. In this simulation, only the Hamming distance is known. This Hamming distance becomes the input the to tolerence evaluation. A separate section explains the concept of Hamming distance in more detail.
The function responsible for calculating Hamming distance is:
unsigned int hamming32( unsigned int x1, unsigned int x2 )
This is a simple parametric function with one variable input, one variable output. The shape of the function can evolve to optimize behaviour. More details, and plots are explained here. In addition to the function itself some noise is injected into both the input and the output of this function, this simulates confusion and just regular mistakes that might happen in day-to-day living. The amount of confusion can be set by recompiling the simulation.
The code can be downloaded here:
The process of converting the raw frames to movies consists of firstly using the "gimp" program to load each frame and apply some blur, then save again under a different name. There is a perl script to make this happen. Then you end up with:
These are then combined together into a single large file of YUV frames, by using the program pnm_YUV4MPEG2 and there is a script that loops through all those frames. Now you have a large file of raw frames (size is approx 400 megabytes) and you can encode this with the theora_encode program that is supplied with many linux distributions. Note the many options on the encoder to control compression, etc. Here are the scripts: