Checking for stagnation in changing arrays. Game of Life.

Hi.
I am making a Game of Life using 8x8 LED matrices and I need some way to check for stagnation in my arrays.

Here are my arrays. I use one array to hold the current values for the matrix and then I update the second buffer and display it.

// Keep the current matrix setup.
unsigned char buffer[8] = { B00000000,
                            B00000000,
                            B00000000,
                            B00000000,
                            B00111000,
                            B00000000,
                            B00000000,
                            B00000000
                          };

// Keep the next life cycle.
unsigned char buffer2[8] = {B00000000,
                            B00000000,
                            B00000000,
                            B00000000,
                            B00000000,
                            B00000000,
                            B00000000,
                            B00000000
                          };

It can happen that the computation of the generations will become a loop between 2 or more frames (lets have an upper bound of 3 for now).

For example the pattern that is in buffer now will loop between two frames. When this happens I want to be able to detect it so I can randomize the array and start over.

Currently I have a method that checks if the previous frame is the same as the one computed and that works fine for when the display comes to a complete stop. That is, when there is no change between a previous frame and the current but that is all I can manage.
Here is the code for my current method:

boolean isSame(){
  for(int i = 0; i < 8; i++){
    if(!(buffer[i] == buffer2[i])){
      return false;
    }
  }
  return true;
}

Does someone know of a nice way to detect repetition between the frames?

Thanks.

Your comparison should work fine. You just need another 8-byte buffer to store the comparison frame. If you want to detect cycles longer than 2 frames (say up to 5) I would use a counter for how many frames to skip between loads of the comparison buffer:

initialize the skip counter to 1.
initialize the comparison buffer to all 0's

Calculate new frame contents.
If the new frame matches the comparison buffer: stagnant.
decrement the skip counter.
if the skip counter is 0, copy the new frame contents into the comparison buffer and set the skip counter to 5 (this new compare buffer will be compared to the next 5 frames)
Update the display

You can compare buffers as 64-bit unsigned long long variables or use memcmp() rather than a loop and flag.

Here are my arrays.

With oh such meaningful names...