I am trying to create a simulation of Conway's Game of Life.
(http://en.wikipedia.org/wiki/Conway's_Game_of_Life)
To do this I need two 2D arrays. One with the current state, and one to create the next generation state on. Then to create the subsequent generation, I must reverse the roles of the arrays so the second is the current generation, and the first is the next generation, and so on. (Similar to flipping in double-buffering).
So far I have made an array[x, y, 2]. The most obvious thing to do is create a variable which is either 0 or 1 to keep track of which array is which. However I was thinking of creating two pointers to the [x, y] part of the array, and not the [2] part. Then swapping around the pointers. So I can just use firstarray[x, y]. But I'm not sure how to do this exactly, or if it's a good solution.
Any advice will be appreciated. Thanks.
(http://en.wikipedia.org/wiki/Conway's_Game_of_Life)
To do this I need two 2D arrays. One with the current state, and one to create the next generation state on. Then to create the subsequent generation, I must reverse the roles of the arrays so the second is the current generation, and the first is the next generation, and so on. (Similar to flipping in double-buffering).
So far I have made an array[x, y, 2]. The most obvious thing to do is create a variable which is either 0 or 1 to keep track of which array is which. However I was thinking of creating two pointers to the [x, y] part of the array, and not the [2] part. Then swapping around the pointers. So I can just use firstarray[x, y]. But I'm not sure how to do this exactly, or if it's a good solution.
Any advice will be appreciated. Thanks.