Cycles (a bit like Conway's Game of Life)

Started by Louigi Verona, May 22, 2009, 19:20:47

Previous topic - Next topic

Louigi Verona

http://www.cathyportal.ru/files/Cycles.zip (1 Mb)

I present to you Cycles - a cellular automation model, which might remind some of Conway's Game of Life, but is based on different principles.
And the first thing you'll notice is that you can hardly interact with it. Some small interaction possibilities will be described further down. Basically, this thing the way it is done now is mostly to observe the process.

You can just run the program, no need to read anything, but for those who are curious - let's see what's going on there.

You'll see several types of cells: "X", "O", "+", "~" and "=".

"X" and "O" are living cells
"+" are egg cells
"~" are larva cells
"=" is void space

Cells of the grid are randomly accessed and the result of the interaction depends on what state is the cell in. Each micro-cycle tries to place a pair of "X" and "O" on the grid, first "X", then "O", their positions relative to each other are random. "X" is more aggressive, taking a role similar to male, and "O" is female.



Rules
Cycle starts with a "big bang" - all cells are alive, meaning that addressing any of them results in either an "X" or "O".

1. If an "X" is placed on "X", it stays "X". Same for "O".

2. If an "X" is placed on an "O" cell or vise versa, an "+" egg cell appears.

3. If an "X" is placed on an "+" egg cell, it destroys it and turns it into "=" void space.

4. If an "O" is placed on an "+" egg cell, it creates a Red Larva cell.

5. If an "X" is placed on a Red Larva cell, it produces an "X" in its place.

6. If an "O" is placed on a Red Larva cell, it creates a Bio Burst, which means that the field it landed on becomes a usual "~" larva. Two more larva in any of the eight directions around the field might appear. Larva may only land on void space, so if "+" an egg is fully surrounded by non-void cells, only one larva will be produced instead of three. Usually an egg will be surrounded by both void and non-void cells and in that case luck will decide whether the additional two larva will be thrown into what of the 8 surrounding cells. All in all, a Bio Burst can produce 1-3 larva cells.

5. Both "X" and "O" can be placed on usual "~" larva cells, that being the main mechanism of reproduction.





Heating up and cooling down of void space
While all of the above exciting fuss is going on, a process of energy transfers, invisible at first, takes on a life of it's own.

All void cells begin with 0 of charge.

6. Each time a void cell is accessed, it tries to obtain an energy charge from the surrounding 8 cells.
-If at least one of them is non-void, it gets a charge from it. A non-void cell does not suffer anything from the transfer and the void cell receives a +5 charge (heating up).
-If all of the surrounding cells are void, it tries to obtain +5 from each of the 8 cells. Such transfers deplete surrounding cells by -5 of charge each and adds +5 to the center cell (cooling down). If some of the cells do not have a +5 charge, nothing happens. So the best outcome is +40 and the worst is 0.

7. Each time an "X" or "O" are placed on the grid, they feed all the surrounding void cells by +5.

8. When the void cell reaches the charge of 150, it becomes a Blue Larva cell.




Space Burst
This is a second reproductive process possible which adds a couple of more rules.

9. If an "X" is placed on a Blue Larva cell, it cools it down about a third, turning it back into a well-charged void cell.

10. If an "O" is placed on a Blue Larva cell, it creates a Space Burst, which places a "~" larva on the center piece on all of the surrounding it void cells, which in the best case gives a total of 9 larva cells, all of which can be populated, thus creating a second reproductive mechanism.





Big Cycle
Sooner or later the big cycle comes to an end and the grid totally cools down. To start the process over you can either click on a grid which would produce random "X" cells and thus revive the cosmos or else choose "Clear" from the menu and Start the cycle over again.

It was my intention to create a "life" which would have an end. Somehow modelling eternally stable processes is boring and besides most processes in the world we observe do actually have a certain end.

However, they also have rhythm and periods. So, this being a first version, I plan to add a phase of reset which means that after the whole grid has cooled down it will be able to accumulate charge to the point of the next Big Bang.


Okay, enjoy the observations and would love to read your comments on this.

Sam_Zen

I'll have to check this out first, but it seems to be an appealing concept.

I once had a, I think similar, program on the ZX81 processor called 'Life' with growing cells.
With the growing according to certain algoritms.

Without seeing the result yet, reading this, I wonder, could this be considered as ASCII-art ?
0.618033988

Louigi Verona

I don't know about art, but it certainly looks appealing to me )

Anyway, I will soon show a second, larger version of this which looks much more neat. I am not tuning the rules so that the model works how I want.

bvanoudtshoorn

Hmm, this is a neat idea, LV.

Have you considered using something like Processing to make it more immediately visual? I went through a phase of using Processing a lot (such as here) , so if you like, we can work on it together -- you give me the rules, and I'll visualise them for you. :)

Louigi Verona

Looks good, but I did visualize it, though not as beautiful. I mean, my automation is in squares )))

Sam_Zen

It's indeed the Life model using a square pixel field with a certain bgcolor, and an ASCII-sign with a certain color.
Fine by me. But so far I see a bit too much random instead of a visual 'grow' process.

2 BvO : Nice work. I understand it's a script thing, but is there a way to DL this, to use it off-line ?
0.618033988

bvanoudtshoorn

[hijack]
(A pre-emptive apology to LV for the slight thread hijack)
Absolutely, Sam_Zen!

There are a couple of ways. The simplest, if you don't want to tweak anything, is to download the JAR file by following this link. Then, depending on your system, you should be able to run it by double-clicking on the downloaded file. If that doesn't work, open up a terminal (in Windows, run 'cmd.exe', on a Mac, the 'Terminal' app, on Linux, run 'gnome-terminal'), browse to the directory you stored the file (in all three, 'cd [the full path here]'), then run the file by typing 'java -jar Swarms.jar'.

If you want to twiddle the knobs, so to speak, then you need to download Processing from this site, then download the three 'PDE' files from the applet page. Store these in the same folder, then, in Processing, open "Swarms". You can now twiddle with the bits and play around. :)
[/hijack]

Ok, enough hijacking. :)

Yeah, you're in squares, but that doesn't mean it doesn't have to be uber-pretty... :D

Sam_Zen

Yep, solly for the hijack, but thanks.
0.618033988

Louigi Verona

True, it is pretty random now. I am continuing to tweak it. Atm I have a version where two colonies fight each other. It is pretty fun to watch but it is still pretty random.

Louigi Verona

Okay, guys! Forget almost everything that I wrote above. It was a nice start but now the cellular automata I would like to present to you uses different, less complex rules, and the model itself is much more elaborate and, plainly speaking, more cool.

http://www.cathyportal.ru/files/Cycles.zip

First of all, the universe is now not an enclosed space, but a torus, which means that it is continuous yet finite, which is a very satisfying concept for me, since I was not happy neither with a "room" nor with "infinite space". In a 2D representation it is simply a rectangle where if you go beyond right border you actually come out from the left, if you go down, you come out from up and vice versa for both cases. The torus has also a great property that it is homogeneous, while a surface like a sphere would have special points - the poles.

Second, the initial idea that the process should be a series of cycles - life, death, rebirth, life, death, rebirth - is now actually there.

Third, the program is very interactive, it starts out as empty space and you get to create cell configurations and see them evolve into complex life and you can also add and delete cells in real time.

=======
I will not tell you in too big a detail how everything works - only if anyone specifically asks for it - and for the moment will stick with what you need to know to start exploring the model on your own.




A small walkthrough.

1. Observe how space cools down.
  When you start up the program, you will see void cells, most of which are coloured in various levels of blue. The more blue the cell, the more charge it has. However, if you go to Cycle->Start and observe, you will see how everything pretty rapidly discharges with several cells getting the most charge and them also loosing energy eventually so that you will be left with absolutely dark cells.

  This is how void space works if left to its own devices. Each void cell that is fully surrounded by other void cells will get a portion of the charge from each one of them in an attempt to fully charge and become an egg which in initial randomly charged space is actually impossible. It is possible, however, when living cells are introduced. Let's see what happens then.

2. Charge a void cell with living cells.
  If a void cell is adjacent to a living cell, it will not receive energy from other void cells, but get charged from a living cell and eventually become an egg that will then hatch out other living cells. But for that to happen it either has got to have enough cells around it to compensate for the loss of the charge to other void cells.

  Perhaps that explanation is a bit confusing for now. Let's try an example.

  By left clicking on the grid, you can produce X cells. Form this construction out of five cells:

  X-X-X
  X-#-X

  Here # is void space. After you've done that, make sure the process has been started (counters below should show numbers, otherwise click Cycle->Start).
  Now as you wait for the result, you will soon notice that the void cell within the construction begins to charge strongly. Sooner or later it will become an egg, usually that takes around 1-2 mins.

  You can create cells in real time and for this explanation it is safe to leave the configuration you just made evolving and create a different configuration in another spot. The suggested configuration will actually evolve much faster:

  X-X-X
  X-#-X
  X-#-X

  As you watch these two configurations, you might see them either start evolving or turn themselves into stable non evolving configurations. For instance, both configurations that I showed you have a tendency to become a square of one gender cells which will then not evolve or else evolve very slowly:

     #-C-#
  #-X-X-X-#
  C-X-X-X-C
  #-X-X-X-#
     #-C-#

The "C" fields indicate void cells which would tend to be charged more than others since they touch upon the maximum number of living cells. But the exposure of those cells to the "cosmos" is pretty serious so this process usually takes a loooong time.

This configuration, however, will work much faster

  X-#-X
  #-X-#

because the cell is secure from the void and all the void cells around it touch on the living cells and will not reduce the charge.

In conclusion to this, the most minimal evolving configuration is this one, though it is also the slowest to charge and evolve:

  X-#
  #-X

Anyway, now that you've experimented with some starting configurations, let's move on!

3. Intermix genders.
So now you can create life by charging void cells. But there is an even faster way to create life, by putting X and O cells together from the start. You know how to place X cells on the grid.  If you want to create O cells, all you have to do is right click on the grid.

By creating configurations that contain both X and O cells, you will almost immediately get evolving life. For instance:

  X-O-X

  or even as simple as X-O, though such configuration will result in a non-evolving or slowly evolving one-gender configuration. That happens because grey eggs (biological eggs) will hatch out only either x or o. But if the egg touches only upon, say, O cells, it will hatch out o. So in X-O configuration one of them will turn into an egg which will deliver babies of another and so eliminate itself completely.

  So it makes sense to make a bit more complex configurations to ensure development, or create simpler, but several of them.

4. Gender wars and what cells mean what.
Basically, how the model behaves is that X and O constantly fight each other. We just saw that hatching is, from some perspective, a pretty aggressive procedure so that once the egg is created what type of cells it hatches out depends on what cells are adjacent to it. But this battle is what makes life evolve - a philosophical principle which seems to be working quite well here. The indicator below shows the number of X and O cells, but since the model is balanced, eventually they'll get evened out and be of about the same amount.

So anyway, the grey cells with a "+" are biological eggs and small "x" and "o" are offspring which eventually become adult cells. The red cells are also offspring, they just mark that there was an egg in this cell. When hatching out, the egg delivers one larva in its own place (the red one) and throws 0-2 larva around itself (white ones).

The blue "~" cells are space eggs, as you've probably already understood, and it throws bluish larva around itself. Space eggs hatch out both genders, not depending on what living cells they are adjacent to and, in fact, don't care if there are any adjacent living cells at all. So space eggs are cool.

5. The decay.
You have probably noticed that as you are observing evolving cells, it says below - Cycle: 1. What does that mean?

Well, what happens when the whole universe is filled with living cells and there are no void cells at all, the "cosmos" will go into a cellular decay phase, as it becomes "tired", drained of ability to hold living cells. You will observe that void cells start to appear here and there and space eggs won't hatch. Eventually, the process will escalate and at one point life will stop and empty space will fill most of the universe, leaving islands of offspring and bio eggs. Usually most adult cells do not survive the procedure.

The decay phase eventually ends, cycle number goes up by 1 and you will see life begin to evolve from what is left. In most cases you will see that what is left are once again basic one-gender configurations like the ones we've tried above, various "L" and other tetris-like shapes. Stranded bio eggs will eventually die if adult cells do not connect with them soon and so new cycle will evolve from few basic shapes. Which is pretty fascinating... at least to me!

It is possible that the configurations left after the decay phase will be non evolving ones in which case it means that the next cycle will not develop without placing additional cells. Basically, it would mean that the process has stopped and life of this universe has ended.

It is fun to see how many cycles life will evolve. However, the process is indeterminate, so you cannot influence the amount of cycles any definite universe will live. Your influence can only be direct - that is, adding cells. But even without adding anything the universe can live many cycles on its own. I have seen it go through as many as 8 cycles and usually universes tend to live long.

Additional controls.
By left double clicking you can create a void cell (a good way to erase individual cells). By right double clicking you can produce a bio egg.



That's it for now!
Enjoy!

Louigi Verona

I know this is not about OMPT at all.... so don't hesitate to tell me that such threads are not welcome (they almost killed me at pouet for posting this), but did anyone try this and found it to be of any interest?

LPChip

Unless a topic does harm to the forum, the software or its users... I don't see a problem. :)

There should be some off-topic chatter, as long as it has a descent value. This certainly has that. I also tried it, but I didn't liked it that much, because it seemed to not be able to actually die that easilly X)
"Heh, maybe I should've joined the compo only because it would've meant I wouldn't have had to worry about a damn EQ or compressor for a change. " - Atlantis
"yes.. I think in this case it was wishful thinking: MPT is makng my life hard so it must be wrong" - Rewbs

Louigi Verona

Yeah, well in the latest implementation it typically won't die. Should it? =)

Sam_Zen

I think the MP forum should welcome any work of a member, no matter what discipline. Posted in the right place of course.
Haven't got the time yet, LV, to check the latest, but I will take it.
0.618033988

Louigi Verona

New version - very fast, very visual and life usually ends within 10 cycles.
http://www.cathyportal.ru/files/Cycles.zip

Screenshot: