My Experiments with Artificial Life

Hello everyone. I decided to tell you about my experiments with evolution simulation.

How it works

The world is divided into square cells. Each cell can contain an object (bot or organic).

The bot has a genome, it acts according to the genome. The bot can look in eight directions around itself. The bot also has 3 main parameters: energy, minerals and age.

Energy is obtained from photosynthesis or processing of minerals (chemosynthesis), each mineral gives 4 energy, minerals accumulate automatically when in the lower part of the world. Below is a map of the distribution of minerals and photosynthesis.

The age at birth of the bot is 1000, each turn it decreases by 1. If age <= 0, the bot will die, leaving behind organics. Energy also decreases each turn, but if it runs out, the bot will die, leaving behind no organics.

If the bot has accumulated a lot of energy (800), it will automatically share, creating a copy of itself on the adjacent cell (in the direction of its gaze).

How much energy and minerals will the bot receive in different layers of the world

How much energy and minerals will the bot receive in different layers of the world

Division

When dividing, the bot spends 150 units of energy. (it is clear that if it has < 150 units of energy, it will die).

If there is enough energy, a copy of the bot is created on the cell next to the bot. If the cell is occupied, a new bot will not appear. The copy receives half of the parent's energy and minerals, its color and genome. A mutation may occur with a 1/4 chance. When mutating, the offspring's genome changes slightly, and the color changes completely.

The work of the genome

Genome is an array of 64 commands from 0 to 63. The bot has a counter that indicates which command the bot will now execute. After executing a command (if it does not shift the counter itself), it jumps over the command with all its parameters.

There are finishing and non-finishing commands. Finishing commands can be executed only once per turn, non-finishing commands – up to 5 times, or until a finishing command is executed.

Below is a table with the names of all the teams and their characteristics.

Team

The final one?

Number of parameters

Number of transitions

23 – turn around

No

1

0

24 – change direction

No

1

0

25 – photosynthesis

Yes

0

0

26 – to walk relatively

Yes

1

0

27 – to be absolutely like

Yes

0

0

28 – attack relatively

Yes

1

0

29 – attack absolutely

Yes

0

0

30 – look relatively

No

1

5

31 – see absolutely

No

0

5

34, 50 – give up some resources relatively

Yes

1

0

35, 52 – give away some of the resources absolutely

Yes

0

0

36 – how much energy do I have?

No

1

2

37 – how many minerals do I have?

No

1

2

38 – convert minerals into energy

Yes

0

0

39 – is photosynthesis possible?

No

0

2

40 – is there an influx of minerals?

No

0

2

41 – share relatively

Yes

1

0

42 – share absolutely

Yes

0

0

43 – what is my position(x)?

No

1

2

44 – what is my position(y)?

No

1

2

45 – what is my age?

No

1

2

46 – uniform distribution of resources relative to

Yes

1

0

47 – uniform distribution of resources is absolutely

Yes

0

0

48 – transition

No

1

2

All others – add the team number to the counter

No

0

0

Relative and Absolute Commands

Some commands can be relative and absolute. A relative command takes the direction from the parameter (in this case, the counter jumps over the parameter), and an absolute command uses the bot's direction.

Sensors

About half of all commands are sensors. They allow the bot to find out how much energy or minerals it has, how much longer it has left to live, who is in front of it, and much more.

The simplest sensors are whether there is an influx of minerals and whether photosynthesis is working. If there is, the transition is made along the first transition, otherwise along the second.

More complex conditions contain a parameter. If the compared value is greater than the parameter, the transition is made by the first transition, otherwise by the second.

The vision sensor has 5 transitions. Depending on what is in front of the bot, a transition will be made along one of the 5 transitions.

Jump – a number after a command that indicates which command the counter should jump to.

Let's look at the basic commands

23 – turn. Turns the bot to the right. [параметр % 8] divisions. This command allows bots to not get stuck in front of any object.

26, 27 – walk. Moves the bot 1 cell in the specified direction, spending 1 unit of energy. If the bot goes beyond the left border of the screen, it appears on the right and vice versa. The world is horizontally looped.

41, 42 – share. The bot creates its descendant. These two commands are practically not used, as there is automatic division.

28, 29 – attack. The bot eats its neighbor, taking all its energy and minerals. Without this command, bots cannot process organic matter.

34, 50, 35, 52 – give away some resources. The bot shares 1/4 of its resources with its neighbor. If the neighbor's energy is more than 1000, it is cut off. Sometimes these commands cause interesting patterns in the energy rendering mode.

29, 30 – look. The basis for higher beings, because it allows to distinguish bots from organics and friends from strangers (if the difference in the genome is small). If there is a border in front of the bot, the transition is made by 1 transition, if nothing – by 2, if an enemy – by 3, if a relative – by 4, and if there is organics in front of the bot – by 5.

Rendering modes

I've already mentioned the energy rendering mode, but there are others. Let's look at them all.

Rendering mode for predators

Power type display mode

Power type display mode

In the food type (or predator) rendering mode, the bot's color depends on its energy sources. If the bot is engaged in photosynthesis, it will be green, if chemosynthesis – blue, predation – red. If the bot receives energy from several sources, the color will be intermediate

Energy rendering mode

Energy display mode

Energy display mode

In energy rendering mode, red bots have a lot of energy, the less energy a bot has, the yellower the bot.

Mineral rendering mode

Mineral display mode

Mineral display mode

In mineral rendering mode, bots without minerals are white, the more minerals a bot has, the bluer it will be.

Age rendering mode

Age display mode

Age display mode

The age rendering mode is similar to the mineral rendering mode. Young bots are white, older ones turn black.

Color rendering mode

Color display mode

Color display mode

Color rendering mode makes no sense without higher beings – colonies. I already said how color works: it is transmitted during division and completely changes during mutation. Bots from one colony most often have one color

Organics

We've talked about bots, now let's talk about organics. Organics only appear if the bot dies of old age. When organics appear, they fall down, but when they touch an obstacle, they stop falling forever.

Organics contain energy that the bot did not have time to spend. Like the bot, organics can be eaten and its energy can be taken for yourself

Interesting creatures

Protozoa

The simplest are bots that do not form clusters. These include several types of stationary solitary bots, mobile predators, and winds.

Winds

Winds

Winds

Winds constantly move to the right or left, while attacking in front of them. Sometimes winds may appear that do not receive energy. They fly faster than their autotrophic counterparts, catch up and eat. This happens due to the fact that the commands for obtaining energy – photosynthesis and the conversion of minerals into energy – are final, that is, they spend a separate turn to complete.

Winds without attack

Winds without attack

Winds without attack

Now about the attack. If the winds do not attack, then at least they will cease to fall into the category of “simplest”. But if you look at the behavior of the creatures, it turns out that they quickly form clusters. However, I have not met such in the natural environment, the winds in the picture were created artificially.

Static predators

Static predators

Static predators

In the early stages of the world's development, static predators are common. They eat everything around them and reproduce quickly. When all the food runs out, static predators die from lack of energy.

Static predators cannot cope with creatures capable of attack, such as colonies and warrens.

Photosynthetic static predators

Photosynthetic static predators

Although most static predators cannot obtain energy on their own, autotrophic static predators sometimes appear. They are much stronger than normal ones, since they do not die out after eating their victims. Often, such static predators occupy the entire world.

Mobile predators

Mobile predators

Mobile predators

Unlike static predators, mobile predators are constantly moving. This helps them in finding prey.

Mobile predators cannot destroy a cluster of bots completely, there are always a few bots left. After that, the survivors begin to reproduce, and are eaten by predators again.

Mobile predators can also generate energy on their own, but are more common than similar static predators.

Spinners

Spinners

Spinners

Like other protozoa, spinners appear only at an early stage of the world's development. Their operating principle is similar to that of mobile predators, only in addition to moving and attacking, spinners rotate by 1 division. Spinners can more often than mobile and static predators receive energy themselves.

Colonial

Colonial creatures are bots that form clusters but are not colonies, meaning they cannot distinguish between enemies and relatives.

Reproducing creatures

The simplest creatures that appear only in the initial population. They can only obtain energy and reproduce, they cannot process organic matter and most often become victims of static predators.

Labyrinths

Mazes – Bots that form lines. Bots in a line attack everyone outside, but do not attack other bots in the line. Due to this, they form clusters that look like mazes.

All mazes work on the same principle, but differ in direction and some features. Most mazes have a diagonal direction, but there are also orthogonal ones. Some mazes have bots at the corners, while others look like a chessboard.

Labyrinths appear only at the initial stages of the world's development. They are also impossible without a relative attack command: if it were not there, it would be impossible to attack in a certain direction, and this is the basis for labyrinths.

Labyrinths 1

Labyrinths 1

Labyrinths 2

Labyrinths 2

Labyrinths 3

Labyrinths 3

Labyrinths 4

Labyrinths 4

Higher

Colonies

Colonies

Colonies

Colonies are some of the few higher beings. They do not attack their relatives and due to this have a denser structure and accumulate more energy. Colonies protect their borders from strangers and because of this form characteristic borders between each other. Sometimes other creatures can live between the borders of two colonies.

Colonies, despite their external similarity, work differently. They may not process organic matter, or they may have no boundaries and live inside other colonies. Some colonies do not produce energy themselves, while others resemble simpler creatures.

Colonies that do not recycle organic matter

Colonies that do not process organic matter 1

Colonies that do not process organic matter 1

There are two types of colonies in this world: organic producers that process minerals, and organic eaters – heterotrophs. When the amount of organics becomes large enough, the organic eaters eat them, clearing space for organic producers.

Colonies that do not process organic matter 2

Colonies that do not process organic matter 2

These colonies look a little different. They reproduce faster, and because of this, the layer of bots is thicker. When the organic matter reaches the boundaries of the colonies, it is eaten by predators living on the boundaries of the colonies.

Flamephiles

Flamephiles

Flamephiles

Flamefish are some of the most interesting creatures. They look unusual, but are extremely rare. These, for example, were created artificially.

Flamephiles will immediately attack in a given direction when they spawn. They will then transfer all of their stored energy in the direction of the attack, attacking all enemies around them, just like normal colonies. This can be seen in this picture:

Flamephiles in energy rendering mode

Flamephiles in energy rendering mode

It can be seen that there is more energy at the end of the flamephile than at the beginning.

Tunnels

Tunnels are a type of colony. They are limited to a certain coordinate due to a position sensor – they cannot generate energy at certain coordinates, but bots on the border can still attack. On the other side live regular colonies without restrictions. They create a border with the second colony, but due to its restriction, the border is very smooth.

There are both vertical and horizontal tunnels.

Tunnels 1

Tunnels 1

Tunnels 2

Tunnels 2

Colonies within colonies

Colonies within colonies are a type of colony. Due to minimal differences in the genome, they are considered relatives, but their behavior may differ from the behavior of the main colony. At the same time, they often differ in some rendering mode.

This happens because there may be unused parts in the genome that become active when mutated. So due to this, behavior can change significantly even with 1 mutation.

Colonies within colonies in predator rendering mode

Colonies within colonies in predator rendering mode

Colonies within colonies in mineral rendering mode

Colonies within colonies in mineral rendering mode

Colonies within colonies in energy rendering mode

Colonies within colonies in energy rendering mode

Colonies in colonies in age rendering mode

Colonies in colonies in age rendering mode

Let's sum it up

As you can see, this simulation is a copy of the foo52 simulation with some changes. In the future, I want to change it a lot, in particular, add recognition of relatives by color, and not by the brain, the ability to look at 2 cells, chemistry for greater variety and a variety of multicellular chains.

In the next article I will tell about various experiments with simulation, from virus to oxygen. I also want to tell about other simulations, I have 5 more.

You can download the code here

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *