⬆️ ⬇️

Evo, part 2 - about crossing

Greetings to you, habrazhiteli!



In continuation of the post “Analog of the game“ Life ”- Evo” I would like to give a more detailed description of the teams of the “gene language” that is used in Evo , and share my thoughts on the methods of crossing individuals in this game.



Genetic code



The genetic code of individuals in Evo is a sequence of bytes of almost unlimited length. In addition, each byte is interpreted as a command for a cellular automaton. The machine has 2 tapes: commands and memory. Accordingly, there are two cmd_ptr and mem_ptr pointers . As the animal's RAM, the variable data is used , with a dimension of 1 byte (8 bits).

Currently there are the following commands:





Sample program



In principle, such a set of commands is enough to make loops and branches. Another question is that describing algorithms in such a language is not as convenient as in C ++, for example.

But for example, I’ll show you a program that makes animals move in a square spiral:

start action_split load_from_mem //load from var1 move_mem_right //save var2 data_dec save_to_mem move_mem_right //save to var3 data_dec save_to_mem //right action_move_right data_dec jump_to_ifnz AnimalCommand(-3) //up load_from_mem data_dec save_to_mem action_move_up data_dec jump_to_ifnz AnimalCommand(-3) //left load_from_mem data_dec save_to_mem action_move_left data_dec jump_to_ifnz AnimalCommand(-3) //down load_from_mem data_dec save_to_mem action_move_down data_dec jump_to_ifnz AnimalCommand(-3) //dec var2 move_mem_left load_from_mem data_dec save_to_mem jump_to_ifnz AnimalCommand(-33) move_mem_left // restore var1 end; 


Three values ​​are loaded into memory: 10, 0, 0. I will not explain the algorithm. I think it's pretty obvious.

This code can be found in mainwindow.cpp : 117.



About mutations



Mutations in the game are now implemented as follows. At the request of the organism to multiply by cloning with a mutation, a clone is created. The clone undergoes mutations in an amount of from 0 to 9 (at the discretion of the great random house). For each mutation, the great random chooses one of 4 options:



')

About crossbreeding



We now turn to reflections on how we cross two organisms. Their code may be of different lengths, they may have different memory.

Here, perhaps, and all the options that immediately come to my head. Over the inheritance of memory is not thinking.

BUT! I forgot about something else. What do you think is better?

  1. At the end of the X rounds, take the Y-most-most and cross them. At the same time kill the entire population, populate the world with these Y individuals and their descendants.
  2. Every X rounds, take Y (from 2 to 5, say) the strongest and cross them, adding their offspring to the population.
  3. The third option - the one that you come up with and write in the comments.


Thoughts on the subject are not thick, of course, but I hope for the rich imagination of the audience.

Thank. Waiting for feedback.

Source: https://habr.com/ru/post/156435/



All Articles