3 Attachment(s)
c++ Assignment: Game of Life
I need help finishing this assignment:confused::
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: Conway's Game of Life - Wikipedia, the free encyclopedia.
Here is how our implementation will work:
(1) The program will ask the user to enter a filename from the console. (Just like the last assignment).
(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.
(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.
View solution (interface must match)(the program will be uploaded to hypergrade)
Here is my current code:
Code:
//Game of Life
//Dylan
#include <iostream>
#include <string>
#include <fstream>
#include <cstring>
using namespace std;
//functions
void GetFile(); //Get filename
char MakeArray(); //Make 2d array
char ChgArray(); //change the array
char GameBoard(); //Game Board
//Global Variables
const int ROW1 =12;
const int COL1 =30;
ifstream myfile;
string filename;
char live = 'x'; //life cells
char dead = '.'; //dead cells
char name [ROW1][COL1]; //12by30 2d array
char name2 [12][30]; //another 12by30 2d array
//end of Global variables
//Main Function
int main()
{
int q; //stops terminal window from quitting after programs ends
//call the functions
GetFile();
MakeArray();
ChgArray();
//GameBoard();
//Stop the Program from quitting
cin >> q; //enter any letter to end the program
return 0;
}
//GetFile Function
void GetFile()
{
cout<<"Enter the filename: \n";
cin>>filename;
return;
}
//MakeArray Function
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;
}
}
//ChgArray Function
char ChgArray()
{
//char name2 [12][30];
for (int r=0; r<12; r++)
{
for (int c=0; c<30; c++)
{
name2[r][c]=name[r][c];
//cout<<name2[r][c];
}
//cout<<endl;
}
}
/*/char GameBaord()
{
//do something
}
/*/
Here is one of the files that the user can open:
Attachment 11521|Attachment 11522|Attachment 11523