Game of Life Help

Here is my current code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//Game of Life
//Dylan Metz
#include <iostream>
#include <string>
#include <fstream>
#include <cstring>

using namespace std;

//function(s)
void GetFile(); //Get filename
char MakeArray(); //Make 2d array 
char ChgArray(); //change the array
//Global Variables
const int ROW1=12;
const int COL1=30;
ifstream myfile;
string filename;
char name [ROW1][COL1];
//end of Global variables
int main()
{
int q; //stops terminal window from quitting	

//call functions
GetFile();
MakeArray();
	
cin>>q;		
return 0;
}

void GetFile()
{
cout<<"Enter the filename: \n";
cin>>filename;
return;
}
//Other Functions
char MakeArray()
{
myfile.open (filename.c_str());
for (int r=0; r<12; r++)
{
	for (int c=0; c<30; c++)
     {
       myfile>>name[r][c];
cout << name[r][c];
      }
      cout << endl;
}
}


Here's the assignment:
Question 1

Conway's Game of Life

For this assignment your are to write a program, that plays Conway's game of Life. See the Wikipedia definition, if
you have never played the game: http://en.wikipedia.org/wiki/Conway's_Game_of_Life.

Here is how our implementation will work:
[b](1) The program will ask the user to enter a filename from the console. (Just like the last assignment).[/b]
[b](2) The initial configuration will be read in from a file, which will be a 12 by 30 two-dimensional array of characters. The game board will be surrounded by all O's.[/b]
(3) The game will be played on 10 by 28 two-dimensional array. (Can you guess why?). A period ('.') will represent a dead cell and an 'X' will represent a live cell.

You will be severely penalized if your program does not have at least three functions.

upload to hypergrade.com
View solution (interface must match)
Ok, what is your question?
I need help on the last part of the assignment. I have the inital file in a 12 by 30 array. Now I need to finish the assignment by having the game being played on a 10 by 28 array.

Here is what the first file "life01.txt" looks like:

1
2
3
4
5
6
7
8
9
10
11
12
OOOOOOOOOOOOOOOOOOOOOOOOOOO000
0............................O
0............................O
0............................O
0..........XX................O
0..........XX................O
0............................O
0............................O
0............................O
0............................O
0............................O
0OOOOOOOOOOOOOOOOOOOOOOOOOOOOO



How do I finish this code????

It should look similar to this: http://pastebin.com/2wUMVZRC (output from hypergrade)

p.s pastebin link will expire in 1 month.
Last edited on
I need help finishing this code. What do I do? I need help with the last part (#3)

I've uploaded my current code, the assignment and what the output looks like to pastebin.

Here they are:

Code:http://pastebin.com/VcYMYHxs

Assignment: http://pastebin.com/2kW5DrWe

Output from HyperGrade: http://pastebin.com/94Q5aCiY

The code will be uploaded to HyperGrade dot com.

Also I use dev c++ for the code.

Thanks in advance!
Topic archived. No new replies allowed.