First, we can create a "State" object which stores the full board. Next, one can write an algorithm to generate a "hash" of the current state. This can be based on any logic. Eg hashcode of string containing all cells with row, col values separated by a delimiter.
Now, all we have to do is to generate a list of states and advance the game further. For every new state, a search can be made on all previous states. Here's where our hash comes in handy, to filter out all states matching our hash to make our search faster. They may or may not be the same since collisions are expected. The better the hash algorithm, the faster our search gets.
My logic is a "brute force" one there could be better ways.
Stephan van Hulst wrote:The final state is the first generation where the game starts to repeat itself.
What's the final state if the game contains a single glider?
The game will never repeat itself to the previous state.
Jim Venolia wrote:Might be quicker to make a list of cells that change each generation. When that list is empty you've got a steady state system. If you save 2-4 lists from prior generations and compare the current changelist to prior changelists you can detect systems that repeat every 2-3-...-whatever cycles.
Your system will work for a Blinker or a Pentadecathlon since after n generations, they are back to where we started from.
Now, lets say we have a simple Blinker and a Lightweight spaceship or a Glider besides it such that they don't interfere. The Blinker will stay at its location and continuously blink till infinity and the Glider will continuously traverse across the direction we point it to till infinity. The "change" will always be unique since the glider is moving infinitely and the blinker oscillates infinitely. It will never have a final state.
The main problem with GoL is however that staring at the consequences soon becomes boring, no matter what rules. Bringing in some colors only helps temporaryly.