Combinations and Permutations Pre-Episode 23 from Samuel Hansen on Vimeo.
Download the Episode
[wpaudio url=”https://www.acmescience.com/Podcasts/CP/cp23.mp3″]
Combinations and Permutations Pre-Episode 23 from Samuel Hansen on Vimeo.
Download the Episode
[wpaudio url=”https://www.acmescience.com/Podcasts/CP/cp23.mp3″]
So about the 2^9 switch vs the if statements…
I think the most effecient way would be to setup a 9-D array of binary values (64 bytes, so not that big really). Then for each timestep for each location you address the array with the binary values of the surrounding and central cells (eg life[1][1][1][0][0][0][0][0][0]=1 for the situation:
111
000
000
so the central cell would turn on.)
Great show btw!
If you are checking everything locally, for each cell, you need to check the state of the cell, and the states of each neighbor. If, on the other hand, you have a library of each global state and the state that it leads to, you only need to check the state of each cell once to determine the next global state (using a binary search tree). If your board has n cells, it translates to a O(n) savings in processing time. The tradeoff, of course, is having to store 2^n outcomes, versus having to store 0 when you're checking things locally. If you have the disk space, and want to run billions of iterations, it might be a consideration.