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 ?
Game Of Life 3D
Started by blackslither, Nov 02 2008 02:14 AM
2 replies to this topic
#1
Posted 02 November 2008 - 02:14 AM
|
|
|
#2
Posted 02 November 2008 - 04:54 AM
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.
#3
Posted 02 November 2008 - 07:32 AM
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.


Sign In
Create Account

Back to top









