![]() I'd appreciate some help as I'm not really sure where to start fixing this. I assume this is an error with the for loops in the main script because when I use the function on that cell only it gives a correct result (5). In each step, live cells with 2 or 3 live neighbors survive, dead cells with 3 live neighbors come alive. Since im quite comfortable in writing C++ its probably not completely awful. This is actually my first program written in C. So i implemented Conways Game of Life using SDL2 for visualization. Lately i got interested in writing some C. To summarize, there is a grid of 'cells' that can be either alive or dead. My programming background is mostly C++/C. Conways Game of Life, also known as the Game of Life or simply Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. For anyone unfamiliar, the problem is set out here. It was popularised by Martin Gardner in his October 1970 column of 'Mathematical Games' in the 'Scientific American' magazine 6. For example it says the cell at row 2 column 2 has 6 alive neighbours, but there are not even 6 alive cells on the grid. Im learning C, so as a practice problem I implemented Conways Game of Life. The Game of Life is a cellular automaton devised by the british mathematician John Horton Conway in 1970. The rules of game is: Any live cells with fewer than two neighbours dies in the next. I also tried to debug it by putting in a disp function to find out what the cellStat function is returning throughout the for loops in the main script (disp(i + " " + j + " = " + alive) ) right underneath the line that finds the number of alive cells surrounding the current cell, and it comes back with interesting results. Here we talk about a simplified version of Conways Game of Life. Here is the command window, the first array is the initial array r But when I run the code the output is not as expected. Main script r = įor example, I have been trying to test this for a glider pattern in Conway's game of life which is the array r in the previous code. Neighbors of a cell are cells that touch that cell. The status of each cell changes each turn of the game (also called a generation) depending on the statuses of that cell's 8 neighbors. %making sure the cell is not counted as its own neighbour The Game of Life (an example of a cellular automaton) is played on an infinite two-dimensional rectangular grid of cells. %this function finds the number of alive cells surrounding it Hey I am working on making Conway's game of life in Matlab for a project and so far I have created a function that finds the number of alive cells around the original cell, which I believe works as I have tested it and played around with it a fair amount, but when I implement it into my main script that contains the conditional rules for the game of life it seems to stop working.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |