I've been doin a project for my C++ class pertaining to Cellular Automata. I'm having a little trouble so before I start I'll give you guys all the details so what I know, you'll know.
Provide the program to state (On or OFF) for all of the elements of a 10 X 10 2D array for some time periods.In a nutshell I know I have to start with an array in "Generation 0" and the code essentially will create a copy but I don't know how to start.
For this program any cell will be ON if 3 or 4 of the 5 relevant cells are ON. Relevant cells are itself and it's neighbors -- up, down, left, and right.
There is NO wrap around so any neighbors in the array are OFF. Input the number of periods the program is to run and all of the cells to be ON at the start of the run.
Use two arrays; one holding the result of the last frame calculations and the new one being created in this time frame. At the ends of each time frame print out the new data array. There must be ON cells on for each iteration.
Use modules to give your program maximum flexibility.
Can you guys help me? I mostly just need a template to create the 2D array and a template to pass in a file. (ie fstream) I never understood how to do that.
Thanks in advance.
EDIT:
Here's a copy of the text file I have to pass in:
ON OFF ON ON OFF OFF OFF OFF ON ON
ON ON OFF ON OFF ON OFF ON ON ON
OFF ON OFF ON ON OFF ON ON OFF OFF
ON OFF OFF ON ON ON ON OFF OFF OFF
ON ON ON ON OFF OFF OFF OFF ON ON
OFF ON ON OFF ON ON ON OFF ON ON
OFF ON OFF ON OFF OFF OFF ON OFF OFF
OFF ON OFF ON OFF ON OFF OFF OFF OFF
ON OFF ON ON ON OFF ON ON ON OFF
ON OFF ON OFF ON OFF OFF OFF ON OFF