Very simple ants simulator.
In order to compile this project you will need to:
- have SFML installed on your system. If you don't know how to do it see this link.
- have CMake installed
Please note that you might need reasonably modern computer in order to run this simulator at the intended framerates.
Detailed explanation here
- Go in the repo folder
cd the/repo/location
- Execute
install.shscript
./install.sh
- Install the right SFML version or compile it (see this)
- Run CMake
- Select the repo location
- Click on
Configure, if you have installed thex64version of SFML, in the pop up window selectx64in theOptionnal platform for generatordrop down
- Click on
Finish - Click on
Generate
- You can now open the generated project and build it.
After building the project, populate the configuration file config.xml as follows:
<?xml version="1.1" encoding="UTF-8"?>
<antsim>
<gui>
<!-- GUI activation --><!-- Options: "true", "false" -->
<activatebool="false" /> <!-- activate GUI --><!-- Fullscreen mode activation; only relevant if GUI is activated --><!-- Options: "true", "false" -->
<fullscreenbool="false" />
</gui>
<simulation>
<!-- Path to the food map image, relative to the working directory (where you run the simulator from) -->
<mappath="/home/kchin/hacking_the_colony/map.bmp" />
<!-- Number of simulation steps (1 * dt per simulation step) -->
<stepsint="50000" />
<!-- Number of trials to repeat -->
<iterationsint="20" />
</simulation>
<total_ants>
<!-- Number of total ants (malicious and not) to simulate -->
<numberint="1024" />
</total_ants>
<patience>
<!-- Counter/patience/cautionary pheromone activation by the non-malicious ants --><!-- Options: "true", "false" -->
<activatebool="true" />
<!-- Period for the patience pheromone to fill up from 0 to max (without any interruption) in units of update cycles (8 * dt per update cycle) --><!-- Options: a single floating point value or a list/array of space delimited floating point values --><!-- E.g., str_arr="100", str_arr="1.0 5 10 20 25.0", etc. -->
<refill_period_rangestr_arr="1000" />
<!-- Maximum value of cautionary pheromone --><!-- Options: a single floating point value or a list/array of space delimited floating point values --><!-- E.g., str_arr="15.0", str_arr="5 10 12.5 20 25.0", etc. -->
<max_rangestr_arr="1000" />
<!-- Evaporation rate of patience pheromone in units of simulation steps (1 * dt) -->
<pheromone_evaporation_multiplierfloat="1" />
</patience>
<malicious_ants>
<!-- Fraction of malicious ants out of the total number of ants --><!-- Options: a floating point value between (inclusive) 0 to 1 -->
<fractionfloat="0.125" />
<!-- Directional focus (by malicious ants, towards the food source) activation --><!-- Options: "true", "false" -->
<focusbool="false" />
<!-- Minimum number of simulation steps of headstart before malicious ants begin their attack -->
<timerint="100" />
<!-- Intensity of fake food pheromone -->
<pheromone_intensity_multiplierfloat="1" />
<!-- Evaporation rate of fake food pheromone in units of simulation steps (1 * dt) -->
<pheromone_evaporation_multiplierfloat="5" />
<!-- Tracing pattern of malicious ants: do the ants follow food, home, or neither pheromones? --><!-- Options: "FOOD", "HOME", "RANDOM" -->
<tracing_patterntype="FOOD" />
</malicious_ants>
<!-- Output CSV data file prefix -->
<csv_outputprefix="output_folder/output_prefix" />
</antsim>Once the configuration file is prepared, run the simulator in the same directory where config.xml resides. (If your installation in the above steps was successful, you should have the executable in the build directory of this repository.)
$ build/AntSimulator
The simulator will now start and the output data will be available in the location you specify in csv_output.
In the CSV files, there will be four columns. They describe
- column 1: the average food bit collected by all the ants.
- column 2: the average food bit delivered by all the ants.
- column 3: the fraction of cooperator (non-malicious) ants that collected food.
- column 4: the fraction of cooperator (non-malicious) ants that delivered food.
| Command | Action |
|---|---|
| P | Pause/Unpause the simulation |
| M | Toggle markers drawing |
| A | Toggle ants drawing |
| S | Toggle max speed mode |
| W | Toggle Wall mode |
| E | Toggle Wall erase mode |
| Right click | Add food |
| Left click | Move view |
| Wheel | Zoom |