
I greet you, collective habra-reason, I congratulate you with the New Year! HOORAY!
Some time ago I decided to comprehend the
almighty Actionscript 3.0. In order to immediately try out this tool, I took up writing a small program that would imitate the life of bacteria. How this thought occurred to me - I won’t remember exactly, but the result was unexpected and quite interesting for me.
Under the cut - a lot of pictures and little text. Description of the program and a couple of experiences.
The essence is simple - bacteria “live” in a limited space (500x500 pixels). Each bacterium is depicted with a blue or red pixel on a white background, depending on its membership in the blue or red population. At once I will make a reservation that the colors here play a purely decorative character. Red bacteria live like blue ones and vice versa.

The bacterium itself is primitive. She crawls in a random direction and randomly slightly changes her velocity vector.
After a random period of time, the bacterium divides into two bacteria, while the speed of the "children" is inherited from the bacteria that gave rise to them (primitive gene transfer).
If a lot of bacteria accumulates in one place, then they begin to die (imitation of lack of food).
The program has a mode (leave a trace) when the previous frame of the animation is not erased, and the new one is drawn over the old one. Thanks to this, it is possible to observe the routes along which bacteria travel. Here is how the movement of one bacterium looks like with its subsequent division:

But the life of bacteria would be wonderful if it were not for us - the scientists who crave research and experimentation. For us, on the right, several instruments of influence on life in the “Petri dish” are provided.
')
All of them seem to me intuitive, but just in case:
First, you can start all over again, kill all the bacteria:

You can set the flow of the medium in any direction, so that the bacteria start to demolish:

You can twist the bacteria in a whirlwind, as if they are poured into the toilet :)

You can have bacteria spread to the side of a mouse click:

Also, by clicking the mouse, you can create new bacteria one by one:

You can control the speed of time flow, increase it, slow it down or stop it completely:

Unfortunately, due to optimization, when this parameter is changed, the calculation of the number of nearby bacteria does not work exactly.
Well, the already known setting, whether to erase the previous frames:

The refresh button erases all previous frames once.
Getting to the most interesting - to the experiments
Let the bacteria breed throughout the territory. By the way - at the bottom displays the population numbers.
Then turn on the not very strong flow to the side. The bacteria will begin to be taken down to the corner, where they will die due to "lack of food." But every time it turns out that there are bacteria that move against the flow. There are not many of them, but they are not blown into a disastrous corner, and they give rise to the same people who are resistant to new conditions. After some time, the entire territory will be occupied by a new population, the average speed of which will be directed against the current. Thus, everything will look like there is no flow at all.
Turning off the flow - the bacteria begins to demolish in the opposite direction. But the strongest survive again ...
Thus, we can talk about some getting used to the new external conditions. In this case, the addiction algorithm was not laid initially.
Bacteria can even get used to a not very strong "whirlwind - flush into the toilet", or vice versa to scattering "tornado" in different directions.
Perhaps addictive, adaptation of real organisms in some cases has a similar nature. Maybe thanks to these mechanisms we now have 4 hands and three eyes.
Or maybe the secret of artificial intelligence lies behind the systems of swarm intelligence. We will find out soon!
Actually flash-program itself:
in contact withFor those who are not registered with VC:
herePS
For those who are not touched by the "intelligence" of bacteria: you can simply dream up and draw interesting pictures:



Pps
Before writing this topic, I looked for some general information on similar topics.
Swarm intelligence in WikipediaSome practical applications:
Algorithm of particle swarm on HabréAnt algorithms on HabréCellular Automaton on WikipediaThanks for attention!
UPD
I add source codes. FlashDevelop.
The code is crooked because I wrote to understand AS3, but quite understandable
source code