hahaharry10 / ConwaysGameOfLife

C project creating Conways Game of Life.
0 stars 0 forks source link

Tile Update Error #12

Closed hahaharry10 closed 2 weeks ago

hahaharry10 commented 2 weeks ago

With current properties:

#define SCREEN_WIDTH 1940
#define SCREEN_HEIGHT 1080
#define GRID_START_X 0
#define GRID_START_Y 40

#define CELL_WIDTH 10
#define CELL_HEIGHT 10
#define CELL_GRID_WIDTH ((SCREEN_WIDTH - GRID_START_X) / CELL_WIDTH)
#define CELL_GRID_HEIGHT ((SCREEN_HEIGHT - GRID_START_Y) / CELL_HEIGHT)

around column 103, the grid does not update correctly.

Look at the following screen recording:

https://github.com/user-attachments/assets/eeca4765-5257-4912-bb9e-00ba7aa605b5

And the corresponding keylog:

Screenshot 2024-08-30 at 13 28 38

The generation is simulated incorrectly creating this incorrect output.

hahaharry10 commented 2 weeks ago

For input:

Input Log

The calculated neighbours are the following:

Neighbour Count

The correct neighbour count is actually:

1 2 3 2 1 0
1 2 4 4 3 1
1 3 4 4 2 1
0 1 2 3 2 1

So, the second-to-last count on the bottom line and the second-to-last count on the penultimate line are incorrectly calculated (calculated as 1 but should be 2).

I suspect the issue is with the logic and cell-checking of the upper-left diagonal neighbour.

hahaharry10 commented 2 weeks ago

fixed in line 37 of commit 8651be6