Azzera filtri
Azzera filtri

How to stop Game of Life when cells can't change but stabilization is not reached

2 visualizzazioni (ultimi 30 giorni)
I have made Game of Life in Matlab and was wondering if there is a way to stop the game. For example, when I have only three cells left in the game and they are all neighbours, the game just continues between two states and I have to pause the code in order to stop the game. But I want to add a rule that if there is no possible change when such a situation is reached, stop the game.
Below is the situation that I am referring to.
All help is appreciated!

Risposte (1)

Walter Roberson
Walter Roberson il 7 Feb 2021
You can stop when the board is empty, or when the board is the same as it was at any previous point.
Comparing the board to the board immediately before is worth doing because you might have settled down to stable blocks like a plain block of 4.
But you need to compare to boards before that, since there are structures of period 3, and of much higher periods. Indeed, "finite oscillators are known to exist for all periods except 19, 38 and 41" and therefore you need an indefinite record, since you just happened to be looking at an oscillator of period 7931236 this time.
Clearly this is going to be a challenge to manage efficiently.
You can use techniques to reduce the search time. For example you can round your board up to a multiple of 8 in each direction, and encode the current state of the board as binary, 8 bits per byte. Then take the collection of bytes and run something like MD5 on them, and use that as a hash table key with the encoded board as the associated. At any one point, run the MD5, look to see if there is an existing key with that signature, check whether the encoded boards are the same; if so you have a cycle and can stop. If the encoded boards are different, you have a hash collision to consider.

Categorie

Scopri di più su Conway's Game of Life in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by