Hi, I'm programming Conway's Game of Life for my c++ class
. I've been working for hours trying to figure out why it's not working, here's the function that checks the neighboring cells
***EDIT - Just to update so everyone knows this is solved. I ended up rewriting the program without a game object. Most of the code is the same, and it worked once I split the copying of the arrays into their own function. No clue why but yeah
Thank you for helping dutch! Sorry for the delay, I needed a break.
Your code doesn't work exactly as needed, I'll put my output below
In your code, the block that increments the n value, is there anything really different about it besides it being much cleaner?
Also, the operation at line 13 does the entire work of my bottom if statements, yeah?
For the output, copying it over messes it up a bit so I hope it makes sense. If you look at the top right section of the starting board pattern, the very top right x dies as it should. However, life is created in the positions right next to and right below that corner. This shouldn't be the case, because those cells had only two neighbors. I've been messing around trying to find out why
1 2 3 4 5 6 7 8 9 10
1 - - - - - - - - - -
2 - X - - - - - - X -
3 - - X - - - - X - -
4 - - - X - - X - - -
5 - - - - X X - - - -
6 - - - - X X - - - -
7 - - - X - - X - - -
8 - - X - - - - X - -
9 - X - - - - - - X -
10 - - - - - - - - - -
Generation: 1
1 2 3 4 5 6 7 8 9 10
1 - - - - - - - - - -
2 - - X - - - - X - -
3 - X X X - - X X X -
4 - - X X X X X X - -
5 - - - X - - X - - -
6 - - - X - - X - - -
7 - - X X X X X X - -
8 - X X X - - X X X -
9 - - X - - - - X - -
10 - - - - - - - - - -
Generation: 2
1 2 3 4 5 6 7 8 9 10
1 - - - - - - - - - -
2 - X X X - - X X X -
3 - X - - - - - - X -
4 - X - - - - - - X -
5 - - - - - - - - - -
6 - - - - - - - - - -
7 - X - - - - - - X -
8 - X - - - - - - X -
9 - X X X - - X X X -
10 - - - - - - - - - -
Generation: 3
1 2 3 4 5 6 7 8 9 10
1 - - X - - - - X - -
2 - X X - - - - X X -
3 X X - - - - - - X X
4 - - - - - - - - - -
5 - - - - - - - - - -
6 - - - - - - - - - -
7 - - - - - - - - - -
8 X X - - - - - - X X
9 - X X - - - - X X -
10 - - X - - - - X - -