i just started a new programming course and feel absolutley overwhelmed compared to my last one, we have to wrtie a program for the game of life.

could somebody point me in the right direction, i am so confused right now...

http://www.comp.mq.edu.au/units/comp125/assignments/ass1/assignment1.html

thanks!

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

const int SIZE = 20;
bool readGrid(string, char [][SIZE]);
void displayGrid(const char [][SIZE]);
// declare more functions if necessary

int main()
{
    string fileName;        // the name of the grid file
    int nGenerations;       // nGenerations is the number of generations
    char grid[SIZE][SIZE];  // a char array consiting of '*' or '.'
    // declare more variables if necessary
    
    cout << "Enter the filename of the grid: " << flush;            // don't modify
    cin >> fileName;                                                // don't modify
    cout << endl;                                                   // don't modify
    
    // add processing for reading and displaying the grid
  
    cout << endl << "How many generations in total? " << flush;     // don't modify
    cin >> nGenerations;                                            // don't modify
    
    // add processing for new grid generations
    
    if (nGenerations == 1)                                                                  // don't modify
      cout << "This is the grid after " << nGenerations << " generation:" << endl << endl;  // don't modify
    else                                                                                    // don't modify 
      cout << "This is the grid after " << nGenerations << " generations:" << endl << endl; // don't modify
    
    // display the grid

    cout << endl;            // don't modify
    system("pause");         // don't modify
    return 0;                // don't modify
}
// implement all declared functions

This code doesn't do much does it? Why does the user have to input the file for the grid? Is this a startup grid, or is the file meant for ouput when the game is done?
You should also think about how to implement the logic of the game.

ps. I know you tried to use code tags, but if you want to know how to use them properly, click here

oops sorry
the user inputs a text file (start up grid)

and the program outputs a grid based on an input of how many generations the user inputs?

i think that make sense?

im fine with the logic, i am just so lost with the implementation...

I think they're meant to write some code where all the "// Add" comments are.

> cout << "Enter the filename of the grid: " << flush; // don't modify
> cin >> fileName; // don't modify
Start simple, write a function to read a file and store it in a grid.
I'm assuming your tutor gave you some example files to play with.

When you think you've done that, then write the display function. This one should be easiest of all (you might try it first if you want).

If you get to the point of being able to have

cout << "Enter the filename of the grid: " << flush; // don't modify
cin >> fileName; // don't modify
cout << endl; // don't modify
readGrid( fileName, grid );
displayGrid( grid );

Then you'll have made reasonable progress.
The output of displayGrid should resemble your input file.

If you get stuck along the way, well then we'll be here to help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.