- Apr 13, 2008
- 147
- 0
- 0
Hey guys. I am new to programming and am taking an introduction class in C++. We have a homework assignment which we are suppose to implement Conway's Game of Life. It's a simple assignment with simple rules but I can't seem to get it to run properly.
Most of the framework of the code was provided by the professor but we had to do the part where we apply the rules of the game. I am having a feeling it is the way I am trying to use memset and memcpy but it could be an error on my part I have an issue finding. I've had two friends look at it but they're not too experienced and can't seem to help.
To code is on pastebin here: http://pastebin.com/96ZKe4TH
(Unsure if it's usually better to just link it or put it within my post)
The rules assigned are the original ones that can be viewed on Wikipedia:
- Any live cell with fewer than two live neighbours dies, as if caused by under-population.
- Any live cell with two or three live neighbours lives on to the next generation.
- Any live cell with more than three live neighbours dies, as if by overcrowding.
- Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
Any hints as to what the issue is and any improvements that could be done would be very welcomed! The input and output will be on the command line and any input is like such: #ofRow [whitespace] #ofColumn
I keep trying to test this and it doesn't work at all:
1 1
1 2
2 1
That should result in 2 2 becoming alive, but it doesn't at all and then a weird pattern repeats after a few generations.
Most of the framework of the code was provided by the professor but we had to do the part where we apply the rules of the game. I am having a feeling it is the way I am trying to use memset and memcpy but it could be an error on my part I have an issue finding. I've had two friends look at it but they're not too experienced and can't seem to help.
To code is on pastebin here: http://pastebin.com/96ZKe4TH
(Unsure if it's usually better to just link it or put it within my post)
The rules assigned are the original ones that can be viewed on Wikipedia:
- Any live cell with fewer than two live neighbours dies, as if caused by under-population.
- Any live cell with two or three live neighbours lives on to the next generation.
- Any live cell with more than three live neighbours dies, as if by overcrowding.
- Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
Any hints as to what the issue is and any improvements that could be done would be very welcomed! The input and output will be on the command line and any input is like such: #ofRow [whitespace] #ofColumn
I keep trying to test this and it doesn't work at all:
1 1
1 2
2 1
That should result in 2 2 becoming alive, but it doesn't at all and then a weird pattern repeats after a few generations.