Doubts conway's game of life

For general discussion about Conway's Game of Life.
Post Reply
virginialuther12
Posts: 1
Joined: March 4th, 2017, 5:06 am

Doubts conway's game of life

Post by virginialuther12 » March 4th, 2017, 5:34 am

Hi guys,
I am writing a macro that is mostly an excel based version of Conway's game of life if you know about Conway's game of life?The trouble is, both birth and death are invented to occur concurrently, and the way I am presently doing it they occur successively so births and deaths that happen earlier in the for loop...next loop affect the results of calculation later on.To solve this, in its place of calculating the fate of a cell based on the value of the 8 cells presently surrounding it, I would like to store the cell values at the end of each loop, and then make a calculation that refers back to these values. so the fate of each cell would then be determined by the 8 subsequent saved values and not the 8 current values.I hope I have explained myself obviously sufficient mostly what I am asking is, how to save the values of each of the cell in the sort at the end of each loop, if the statement within a loop can refer back to these values, in its place of referring to the present values.
Last edited by dvgrn on March 4th, 2017, 8:40 am, edited 1 time in total.
Reason: removed a spam advertising link on the word "writing"

User avatar
blah
Posts: 311
Joined: April 9th, 2016, 7:22 pm

Re: Doubts conway's game of life

Post by blah » March 4th, 2017, 7:08 am

If I understand your question right, the simple solution is to have two arrays; one containing the state of all the cells, and another containing what their states will be in the future. You iterate through the first array while writing to the second array, and then you go through and copy the second array into the first. I'm not sure about how Excel works, but if you can only have one array I guess you could have each cell be able to contain two values, one being its state, and another being what it will become. Does that make sense?
succ

User avatar
dvgrn
Moderator
Posts: 10612
Joined: May 17th, 2009, 11:00 pm
Location: Madison, WI
Contact:

Re: Doubts conway's game of life

Post by dvgrn » March 4th, 2017, 8:38 am

blah wrote:I'm not sure about how Excel works, but if you can only have one array I guess you could have each cell be able to contain two values, one being its state, and another being what it will become. Does that make sense?
The classic trick is to use two arrays -- two different sheets in an Excel workbook, in this case -- and swap back and forth between them.

Use Sheet A to calculate the new states and store them in the corresponding cells in Sheet B, and then on the next tick use Sheet B to figure out the next generation and put the results back in Sheet A, overwriting all the old cell states there.

If you want everything to happen in one sheet, just copy all of Sheet B's contents back into Sheet A after every cycle instead of switching back and forth. It's a little slower, but Excel macros aren't going to be setting any Life simulation speed records anyway...!

User avatar
rowett
Moderator
Posts: 3776
Joined: January 31st, 2013, 2:34 am
Location: UK
Contact:

Re: Doubts conway's game of life

Post by rowett » March 4th, 2017, 11:19 am

You can do it in Excel without any macros by using Array Formula. See here for an introduction.

User avatar
Mr. Missed Her
Posts: 90
Joined: December 7th, 2016, 12:27 pm
Location: Somewhere within [time in years since this was entered] light-years of you.

Re: Doubts conway's game of life

Post by Mr. Missed Her » March 4th, 2017, 3:00 pm

Maybe it helps to think about it this way:
Simulate a CA with six states, three off states, 0, 0s, 0t, and three on states, 1, 1s, 1t. Start out with only 0 and 1 states, no s's or t's. Every 0 with 3 of any 1 states adjacent becomes a 0t in the next gen, otherwise it becomes 0s. Every 1 with 2 or 3 of any 1 states adjacent becomes a 1s in the next gen, otherwise it becomes 1t. And every 0t and 1s will become a 1, and every 0s and 1t will become a 0. This should simulate life with every 2 gens = 1 life gen, no matter how you check and set the cells. (Unless you check some twice!) It'd also be interesting to see what happens if you simulate this incorrectly, starting out with some s's and t's and some non- s's and t's.
There is life on Mars. We put it there with not-completely-sterilized rovers.
And, for that matter, the Moon, Jupiter, Titan, and 67P/Churyumov–Gerasimenko.

Post Reply