Hey guys, have any of you written the code for or are familiar with the game of life, invented by John H. Conway? I have the layout of what is expected in the abstract, however, I have no idea how to begin.
The game is played on a board consisting of n squares in horizontal and vertical directions whre n is alwasy between 10-25. Each square can be empty or contain an X indicating the presence of an organism. Every square (except the border squares) has eight neighbors.
The program should read in number n. Then in a loop read initial configureation of organisms and print the orig. game array. It should calculate the next array into the original game aarry, and repeat for cycle of 8 generations. A function should be written to calculate the number of neighbors for each organism.
this is the formula to calculate the next generation (the whole point of the game):
1. If an empty square has exactly 2 neighbors an organism is born there
2. If an organism has less than 3 neighbors then it dies of loneliness.
3. If an organism has more then 3 neighbors then it dies of overcrowding
also teacher gave hint of using an array of size n+2 thus forming a border around the actual array. Assume that these borders of the game array are infertile regions where organisms can neither survive nor be born; you will not have to process the border squares. Thus the array will be declared of size (27,27)
ok thats the basic layout of the game, here is my thoughts so far. I dont need anyone to write the code, as I am really trying to learn this language and how it works. I would love someone to work with me through the problem and help me understand this.
The board can be randomly generated or controlled by manually assigning the x's (ie. (row 1, col 3 = x)
This pgm will need 2 arrays, an new one and an old one.
Should my first step be how to assign the X's?; writing the function?; ? I always get stuck at the beginning of problems like this
Anyone help describe this game/program in more easy to understand lingo to help me grip what the program really does, etc?