📜 ⬆️ ⬇️

Play the creator of all things

Introduction


Since long ago, when there was nothing better than the ZX-Spectrum, I remembered a toy, in which I had to set a program for the robot, so that it could defeat the enemy in independent navigation. And in my free time from work and rest, I started working on a program that, with the help of settings read from a text file in XML format, allows you to:



The main difference from existing games is that there is no predefined end to the model in the model.


World of model


The picture shows the world - a large spot is sunlight (moves over time), two smaller spots are sources of another type of energy, called geothermal. The lighted surface is predominantly blue because it contains water at each point. Dots of a different color appear and disappear if, due to diffusion, the relative concentration of the corresponding element is temporarily above average.


Pic1


To save memory consumption, the amount of substance at each point is stored in a real type float, which gives 7 significant digits. For the model, 100,000 units were set at each point of the water, 20,000 carbon dioxide, 10 units of hydrogen (that is, ten thousand times less than water), and zero oxygen and methane. An example of how the description of substances introduced into the model looks like:


<Element name="CarbonDioxide" color="yellow" volatility="0.12" visibility="true"> <rect left="0" top="0" right="max" bottom="max" amount="20000"/> </Element> <Element name="Oxygen" color="green" volatility="0.12" visibility="false"> <rect left="0" top="0" right="max" bottom="max" amount="0"/> </Element> ... 

Next was described the reaction of the formation of methane and water from carbon dioxide and hydrogen in the presence of geothermal energy.


 <Reaction name="CO2+4H2=CH4+2H2O" geothermalEnergy="0.00001" solarEnergy="0"> <LeftReagent name="CarbonDioxide" amount="1"/> <LeftReagent name="Hydrogen" amount="4"/> <RightReagent name="Methane" amount="1"/> <RightReagent name="Water" amount="2"/> </Reaction> 

The first LUCA prototype with this reaction was planted inside one of the geothermal sources.


 <section name="Organisms"> <item name="LUCA" author="DEMI" x="300" y="30" reaction="CO2+4H2=CH4+2H2O"/> </section> 

Further, the program included a filter to show the points containing methane and a spot of methane began to spread around the body. The first cell can receive substances only from the point where it is located, and the transfer of substances is due to diffusion. If you reduce the amount of available substances, the rate of propagation of the reaction products slows down dramatically.


Pic2


The program implements an approximation mode, when a point is increased to a square, which displays a list of substances and living organisms contained in it. If the filter for several elements is turned on, then the color of the element with the highest relative concentration at the given point is used to color the point, otherwise it would always be possible to see only the water with the most


Pic.3


Selection


The starting materials are abundant, but sooner or later they will all be exhausted. If a cell successfully digests food, it accumulates “fat” (internal energy) and can multiply by dividing, and mutate in dividing. Or die with exhaustion. Her behavior is also inherited and susceptible to mutations, during which an insignificant part of the parameters of the cellular automaton changes. Further, controlled mutations will be introduced into the model, when the user will only indicate for which type which mutation he would like to receive. The expected mutation will occur with some probability and the new species must be able to survive in order to mutate further.


So, we have a kind of a protogen-methanogen, which needs geothermal energy. It settles in the zone of geothermal energy, and those individual species that diffusion takes out of its limits - die. Dead organisms continue to occupy space for some time, and then, if no one has eaten them, they disappear. The consumption of mineral substances for the growth of organisms is not realized, respectively, when they decay, they simply disappear. After starting the simulation, organisms multiply rapidly, occupying the entire area around the geothermal source. After some time, dead cells appear outside of the geothermal energy. It is interesting that sometimes it is possible to notice that organisms die in the very center - those who lacked mineral substances, they all ate on the approaches. The figure shows living organisms white and dead brown, blue is water, the pink circle shows the area where geothermal energy is felt (its intensity decreases with distance from the center).


Pic.4


The world described several sources of geothermal energy, the first proto-organism was planted in one of them. When the simulation lasted long enough (several hours), I was surprised to find that the neighboring source was also populated - some body was lucky to get to it alive.


No matter how great the world is, if only one reaction takes place in it, all carbon dioxide (or hydrogen) will be used up sooner or later, after which all organisms will die of starvation, leaving behind vast amounts of methane.


The image includes a display of a living organism and methane (a violet spot that has grown around a geothermal source) showing the backlight from the Sun (the first rays begin to hit the methane spot early in the morning, the sun is to the right, and black is displayed, because organisms) and after the inclusion of full coverage.


Pic.5


If you set a very poor distribution of mineral resources, the population is on the verge of survival - no more than a few dozen individuals. The figure shows a variant when initially there was only two hydrogen reactions at each point.


Pic.6


In the Snapshoot2017.rar file, there is an executable file compiled under Windows and its supporting files. It does not require any installation, it does not leave any traces of its work - to launch, simply unzip it and then delete it. To change the default settings - the ThemeAero / template.demi file can be opened in a simple text editor. The controls are described in the corresponding wiki section of the project.


Future plans


The selection of organisms based on their luck and variability acts. Now we need to go to evolution, while manual. Add a mutation to the configuration file - an organism with a backlash that does not require external energy, but is much less effective. Now, when a proto-organism is divided, there will rarely be a child species that is no longer tied to a source of geothermal energy, but needs a waste product of the first type. As a result, there must be a balance between the two species.


Next we have untapped solar energy. At one point in space can be only one organism, which causes them to compete not only for energy and matter, but also for space.


Conclusion


At the moment, the main difficulty is to choose a ratio of the existing objects of the model so that it remains stable and interesting. This ratio of the volumes of mineral substances, energies, rates, metabolic reactions, and then the tasks from the “living nature” area — how to ensure coding of cellular automata. More precisely, we just need data about the world in an adapted form. "DNA" must be compact, capable of atomic non-destructive mutations, describe both the structure of the organism (the cell array - the nervous system, the receptor, muscle, armor, etc.), and the algorithm of its action.


In the distant future, the model may become distributed - each user has his own garden, where he breeds his organisms, scattering around the district, and into which living creatures from the neighbors fall. The toughness can be measured as the prevalence of the species.


For me, this project is entertainment and I do not plan to extract any benefit. And the purpose of the article is to search for people who are interested in this area, who can share their insights and ideas.


In the program, the model is technically calculated in a separate stream, its speed can be estimated by how fast the model time is running and, accordingly, does not depend on the scale and detail of the image on the screen. There is also a separate stream that visualizes a picture from the world of the model. Its speed is higher, the fewer points of the model are displayed - for example, when with a high magnification a small number of points fit on the screen, fps is higher than when at maximum distance on the screen the whole world is on a wide monitor. In the upper left corner, the display speed is displayed, which is limited to 60 fps, meaningless faster.


PS: The model is open source under GNU GPL Version 3, June 29, 2007 and is available for download to anyone for experimentation or to create forks. It is assembled with ClanLib cross-platform library on MS VSС2015. The binary file under OS Windows lies in the archive - it is not installed at all, but simply launched after unpacking. I assume that compiling for other platforms will not cause problems. Template.xml can be edited in a suitable text editor, some documentation is on the github in the wiki section.



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