Greetings to you, habrazhiteli!

I recently read an article about the
game Life , and I remembered that in May of this year I began to write
my own project of a similar orientation. Only now the interest in him for the routine work quickly faded away, although it was written a lot. And now, inspired by this article, I took this project from the dusty shelf and added a few features, which I will discuss later.
In short,
my version has the following conditions:
- life develops on the field of 256 * 256 cells;
- Objects of three types can be placed on the field: animals , food (let's call it grass) and stone (obstacle);
- the living creature is actually a modified Turing machine ; more precisely, it is more like an Automaton with store memory , i.e. animal life is a "processor" that executes its "genetic" code;
- poultry has the ability to perform certain actions (to move, to eat, to multiply (so far only by cloning, mutations will be from day to day, crossing in perspective)), giving the appropriate commands;
- stepping on the grass, its living creatures trample down;
- To absorb food, you must give the command "Eat in this direction!", while in the next cell;
- animals have a memory that allows building cycles, conditions, etc., i.e. Turing full (correct me if not right!), the amount of memory is unlimited;
- animals can add and subtract values ​​in the mind, the width is limited to one byte;
- There is the possibility of implementing genetic algorithms (not yet implemented).
Who are interested in the details, please under the cat!
Short description
I called the program
Evo (
git ), since it was originally planned for organisms to evolve there. But nothing prevents the very description of the behavior of living creatures and load it into the program. At the moment, only editing the code (in
MainWindow :: MainWindow () ), but loading the living creatures will be implemented soon.
Evo is written in
C ++ / Qt .
The efficiency has been tested only under Linux , although the program should work on any platform supported by the Qt library.
To get a binary, just run:
git clone git@github.com:icoz/evo.git cd evo qmake make
So, at the start a window appears with several buttons. We start and observe how the field is filled with colors.

')
I will explain what color has:
- emptiness is white;
- stone - red;
- the grass is, of course, green;
- and in blue I singled out animals.
At the start, the genetic code of the living creatures is generated using the DSCH. So there is no magic. True, later
magic appears ! Something arbitrarily generated begins to crawl, eat each other, and pasture too.
There are a few simple rules:
- Every 150 (by default) rounds on the field, from 100 to 1100 grass cells are thrown up to compensate for eating and trampling, and only an unoccupied cell is searched for each blade of grass.
- Every 500 (default) rounds, 150 randomly generated live creatures are added, which also begin to try to survive.
- When the population exceeds 1500 individuals, cleaning is carried out: all animals that have fitness == 0 are killed.
Logical partitioning is as follows.
The field (class Map) implements the functions of storing and moving objects, as well as the function of scattering a given amount of food.
The world (World class) describes the interaction of living creatures with the outside world.
Animals (instances of the class Animal) are automata, whose program is the “genetic” code (and I remind you that each individual has a memory and the ability to add and subtract in mind). In the process of executing this code, the body makes or other decisions. The world handles these requests (all this is implemented through a system of signals / slots).
In the case of acceptable behavior, animals are rewarded with an increase in the
fitness parameter. For the absorption of grass
fitness increases by
1 , for eating other animals -
+10 , for reproduction -
+50 . The higher the value of
fitness , the more successful the body. In fact, this parameter describes the vitality of the organism. By the way, I am waiting for your proposals for the introduction of new rules in order to make life difficult for these lovely creatures and force them to invent something new.
Implemented all this mess so:
It should be noted that the work was done to optimize the program so that it does not absorb tons of resources. But in view of the specifics of her work - she loads percent. The slowest is frame rendering, so by default, only every 100th round is drawn.
When saving the living creature, not only the binary code is saved, but a text file with the extension
* .code is created , in which the decoding of this code is given.
What else do you want to do
The wish list is:
- There is not enough implementation of genetic algorithms to be able to select the most survivable individuals and cross them. The implementation of crossing is the most difficult thing for me, because in fact we need to cross 2 sets of bytecode. (If there are ideas of algorithms - please in the comments).
- It may make sense to revise the set of available commands.
- I would like to realize the animal "vision", i.e. ability to determine the type of neighboring cells
- It is possible to modify the generator so that the generation of living creatures goes not at random, but taking into account the weights of commands.
- Consider options for how to parallelize the calculations to improve performance.
- Write an editor for the “genetic” code so that it would be convenient to develop living creatures yourself.
What will be done soon
The list of upcoming changes is as follows:
- At reproduction in the "genetic" code mutations will be made.
- When you click "Save Current Picture", you will be prompted for a file name to save the current map.
- It will be possible to load the saved living animals.
- Possibility of loading several live creatures from the folder at the start (the working name is Autorun-folder ).
At last
While I was starting to write this note, this program was spinning in my background (on the fourth hemp and there was no optimization of work speed). At that time, I reached for the living creature
fitness = 3441 . For this, more than 210,000 individuals lived and died, and more than 6,500 rounds passed.
To get really interesting creatures that knew something interesting, you need (according to my estimates) at least 10 ^ 6 rounds. Maybe someone more powerful computer, twist? But it will be more interesting, of course, when genetic algorithms and a more intelligent generator of initial sets will be implemented. Well, with the addition of generated living creatures individuals written by living people. This will give a good start for future generations.
Having driven the program on core i5, I rather quickly got walking herds. Vitality has already reached 10390 units!
It is interesting to watch these cute little creatures. Even you begin to empathize with them.
Finally, here are some interesting "life" pictures. Visible migration routes of populations, the formation of herds.


The most serious result is 36480 (this is after 10 hours of work and 2 * 10 ^ 6 rounds):

Download, run, watch!
Who cares, you can try to write bots and see who is stronger!
That's all. Thanks for attention!
Bug reports and new feature suggestions are welcome.
UPD: the mutation is already implemented at a basic level.
UPD2:
Bug TrackerUPD3: dtf thanks for Windows binariesUPD4: thanks to
dtf for
new binaries for windows