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
Collapse
X
-
Tags: None
-
Don't use such a big fat int a[][][] block. Use a set that stores only the living cells
in the 'world' and possibly the cells adjacent to those cells. It complicates the
calculation for the next generation a bit but you have to do much less of those
calculations. It's a real speedup.
kind regards,
Jos
Comment