Game Of Life 3D

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • blackslither
    New Member
    • Oct 2008
    • 5

    Game Of Life 3D

    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 ?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    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

    Working...