README (2961B)
This program is a terrarium of little bots who undergo ruthless evolution in a 2D world with it’s own rules.
Usage
The code is written in Pixilang and could either be ran through the graphical manager, or a command line. Anyhow, execute main.pixi file. Read more regarding the language on it’s documentation.
Explanations
The behavior of the world and bots could easily be modified though changing the values of constant variables in main.pixi file.
First of all, the map gets generated by filling it with the following colored cells:
Every bot is then gets assigned the variables of hunger and thirst. While both of the variables values are greater than 0 - a bot is considered ‘alive’. A bot ‘dies’ when either hunger and/or thirst value gets equal or less than 0. A ‘dead’ bot changes color and acts like an empty cell:
Each bot’s values of hunger and thirst change once it done executing a command from it’s genome. A genome here is an array of random numbers from 0 to 15, representing one of 16 possible commands.
Commands with numbers 0-7 are for displacement in 8 directions:
0 1 2
3 . 4
5 6 7
For example, command 5 would mean for a bot to move to the cell which is diagonally to the lower-left (one cell down and one cell left).
Commands with numbers 8-15 are for consumption in 8 directions:
8 9 10
11 . 12
13 14 15
For example, command 12 would mean for a bot to eat or drink (depending on whether it is food or water) from the cell to it’s right.
Execution of one command decreases the values of hunger and thirst by 1. However, bot can increase these values by successfully completing a consumption command on a food or water cell, thus, keeping it alive for longer.
Bots wait in queue to execute commands from their genome and they can only execute 1 command per turn. This queue is looped until more than half of all bots on the map ‘die’. To restore the population - the ‘dead’ bots are randomly re-spawned near still ‘alive’ relatives. The ‘children’ bots that have just re-spawned are assigned the same genome as their ‘parent’ bot nearby which they appeared, with a small chance of mutation. Each mutation has a chance to alter 1 or more commands within ‘child’ bot’s genome causing it to behave a differently that it’s ‘parent’.
After that a new ‘generation’ of bots stands in a queue to execute one of their genome commands, to hopefully outperform their parents.