Can you help me with the bug in this simulation ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can you help me with the bug in this simulation ?

I was making a c# simulation on conway's game of life. I make it working but i than checked with some other simulators out there, and it don't give the same results..? My simulation is based in a wrap around world. You can change the grid (cols, rows). Please help me out! Thankyou..! https://code.sololearn.com/cN5pbfrAM0UV/?ref=app

1st May 2021, 3:36 AM
ACADEMIC
ACADEMIC - avatar
2 Answers
+ 1
In conways game of life you check each piece for its neighbours. In you movement loop your code iterates at for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { but then you should not use the value i=0 && j=0 for this is the element itself.
1st May 2021, 3:27 PM
bernborgess
bernborgess - avatar
0
But then i subtract the value of itself just after that loop..?
1st May 2021, 3:29 PM
ACADEMIC
ACADEMIC - avatar