As far as I remember, in Conway’s "Game of Life" each cell can only be "alive" or "dead".
Means that you need exactly one bit
of storage for each cell, right?
Hence you could use one 64-bit word
, e.g. unit64_t
, to store a grid of 8×8 = 64 cells.
, which is usually 32-Bit in size, won't be sufficient for 8×8 cells)
Of course, you
need to decide how to arrange the 64 cells (bits) within the 64-Bit
Order could be "row-major" or "column-major":
If you want a larger grid than 8×8, you need multiple 64-Bit
words, i.e. an array of unit64_t
, each of which represents a 8×8 sub-grid. Again, you
need to decide how to arrange them.
Once you have decided how to arrange the individual cells within a single 64-Bit
how to arrange the 8x8 sub-grids within the array of 64-Bit
words, it should be relatively straight-forward to write a function that gets or sets the "bit" for a specific cell, by its x
index (position) in the "global" (overall) grid.
This function would first
have to find the right 64-Bit word within the array of 64-Bit words, and then
it would have to get/set the right bit in that 64-Bit word, by using some bit-shift + bitwise "and"/"or" operations.
Given such a function, implementing the "Game of Life" update algorithm will then be possible without
having to bother about how the data is actually stored internally.
Maybe you want to draw a little picture (sketch) first, in order to illustrate the desired arrangement.