Jump to content

Game Of Life 3D

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
blackslither

blackslither

    Newbie

  • Members
  • Pip
  • 2 posts
I had to implement Game of Life in a 3D matrix (int a[ ][ ][ ]) , but the complexity of my implementation is O(n^6) (6 imbricated for) and it runs very slow . Can anyone help me with an optimized version of Game of life , even with a 2D matrix . Or how the Game of Life in general could be optimized ?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Your efficiency seems insanely poor. How did you calculate it, and against what? Generally, you need to do two passes through your array: 1 to get new values, 1 to set new values. If you are using an actual array, that may be part of your problem. A game of life is usually characterized mainly by empty cells, so a sparse array, a bit array, or some other data structure is often more efficient.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Aereshaa

Aereshaa

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 790 posts
In my implementation, you just have two buffers. You copy one buffer into the other, then read one buffer while assigning values to the other. Then display the new values.