C GAME OF LIFE UNIQUE PROJECT HELP WILL PAY VIA VENMO APPPAY

C++ GAME OF LIFE UNIQUE PROJECT HELP **WILL PAY VIA VENMO APP/PAYPALL** thank you

complete the code with unique comments given

The game is called Game of Life:

Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.

Any live cell with two or three live neighbours lives on to the next generation.

Any live cell with more than three live neighbours dies, as if by overpopulation.

Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

https://en.wikipedia.org/wiki/Conway\'s_Game_of_Life

for the implementation / main please explain in comments whats going so I can follow

THIS IS THE .H MUST BE STRICTLY FOLLOWED

need main, cpp, class implementation, the txt file seed that starts/seeds the program

#include // Provides ostream

#include // String operations

#include // Randomizer

namespace csci231

{

   using std::string;

   using std::ostream;

   using std::istream;

   class Cell

   {

       friend class GameOfLife;

   public:

       static const char alive =\'o\'; // alive image

       static const char dead = \'-\'; // dead image

  

       // Default constructor sets the cell\'s state to false

       Cell();

       // Custom constructor sets the cell\'s state as per argument

       Cell(bool state);

       // Empty destructor

       ~Cell();

       // Accessors have no intention to modify the object, so it is a good practice to make them \'const\' functions

       bool getState() const;

       // Mutator to change cell\'s state

       void setState(bool newState);

      

       // Accessor to see the \'face\'

       char getFace() const;

   private:

       bool state;

       char face;

      

   };

class GameOfLife

{

      

public:

       static const unsigned int MAX_BOARD = 30;

  

       GameOfLife();

       GameOfLife(size_t boardSize);

       ~GameOfLife();

  

       int seedBoard(string fileName);

       void seedBoard(size_t seeds);

       void run();

       void run(unsigned int numberOfIterations);

       // ADVANCED

       // A const(!) accessor method that returns a handle to the private currentLife array.

       // The return type must also be \'const\' because we return a pointer to a static array, and these are fixed

       // It is just an example. It is not needed if we have a friend operator.      

       const Cell(*getCurrentLife() const )[MAX_BOARD+2] { return currentLife; };

       ///////////////////////////////////////////////////////

       // friend operator can access private members of GameOfLife

       friend ostream& operator << (ostream& out, const GameOfLife& board);

       friend istream& operator >> (istream& in, const GameOfLife& board);

      

private:      

       bool executeRules(unsigned int countAlive, bool currentState);

       // With \"Halo\" approach we need a bigger board

       Cell currentLife[MAX_BOARD + 2][MAX_BOARD + 2];

       Cell nextLife[MAX_BOARD + 2][MAX_BOARD + 2];

       // ADVANCED

       // Example how to declare variable cl as a pointer/handle to our array of Cells of size HALO_BOARD

       // The accessor method getCurrentLife() above uses the same syntax for the return type

       const Cell(*cl)[MAX_BOARD + 2] = currentLife;

       ////////////////////////////////////////////////////////

  

      size_t boardSize; // Board size requested in the constructor  

};

  

// NON-MEMBER OUTPUT FUNCTIONS

// Display cell\'s state with alive/dead face

   ostream& operator << (ostream& out, const Cell& cell);

  

}

Solution

#include <iostream>

#include <string>

#include <fstream>

#include <cstring>

using namespace std;

//function(s)

void GetFile(); //Get filename

bool MakeArray(); //Make 2d array

char ChgArray(); //change the array

char GameBoard(); //Game Board

//Global Variables

const int ROW1 =12;

const int COL1 =30;

const int BOARD_ROWS(10);

const int BOARD_COLS(28);

ifstream myfile;

string filename;

char live = \'X\';

char dead = \'.\';

// From what the output is supposed to

// look like the \'O\' are not there so

// the row should be 10 and the columns

// should be 28

char board [BOARD_ROWS][BOARD_COLS];

//end of Global variables

int main()

{

    int q; //stops terminal window from quitting  

    //call functions

    GetFile();

    if ( MakeArray() ) {

      // I put this loop in because the output link you gave

      // had a print of 10 boards

      for ( int i(0); i <10; i++)

         ChgArray();

    }

    else {

      cout << \"Error parsing input file\" << endl;

    }

    //Stop Program from quitting    

    cin >> q;   

    return 0;

}

   

//Other Functions

void GetFile()

{

    cout<<\"Enter the filename: \ \";

    cin>>filename;

    return;

}

   

bool MakeArray()

{

    bool ret(false);

    char val;

    int totCnt(BOARD_ROWS*BOARD_COLS);

    myfile.open (filename.c_str());

    if ( myfile ) {

       for (int r=0; r<ROW1; r++)

       {

            for (int c=0; c<COL1; c++)

          {

             myfile>>val;

             if ( val == dead || val == live ) {

                board[r-1][c-1] = val;

                totCnt--;

             }

          }

       }

       if ( !totCnt ) {

         ret = true;

       }

       myfile.close();

    }

    return ret;

}

char getNextState(char b[BOARD_ROWS][BOARD_COLS], int r, int c)

{

   char ret;

   // In this function you want to count the number of \'X\' around

   // the point b[r][c] to see if it will live or die

  

   // Code the rules:

   // 1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.

   // 2. Any live cell with two or three live neighbours lives on to the next generation.

   // 3. Any live cell with more than three live neighbours dies, as if by overcrowding.

   // 4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

   // The thing that get tricky is the boundaries, i.e. when the row is 0 or 9 and column is 0 or 27.

   // Start with the easy one in the middle and then start to test the boundaries.

   // The return will be \'X\' or \'.\'

   return ret;

}

char ChgArray()

{

    char boardTmp[BOARD_ROWS][BOARD_COLS];

    for (int r=0; r<BOARD_ROWS; r++)

    {

          for (int c=0; c<BOARD_COLS; c++)

          {

            // Compute what the new value should be and save it

            boardTmp[r][c] = getNextState(board,r,c);

=            // -----> Not having all of the input files to test

            //              with I don\'t know if you are to print

            //              before the first iteration or after!

            cout << boardTmp[r][c];

          }

          cout<<endl;  

    }

    // Save off the new board value

    memcpy(board,boardTmp,sizeof(board));

    cout << endl;

}

C++ GAME OF LIFE UNIQUE PROJECT HELP **WILL PAY VIA VENMO APP/PAYPALL** thank you complete the code with unique comments given The game is called Game of Life:
C++ GAME OF LIFE UNIQUE PROJECT HELP **WILL PAY VIA VENMO APP/PAYPALL** thank you complete the code with unique comments given The game is called Game of Life:
C++ GAME OF LIFE UNIQUE PROJECT HELP **WILL PAY VIA VENMO APP/PAYPALL** thank you complete the code with unique comments given The game is called Game of Life:
C++ GAME OF LIFE UNIQUE PROJECT HELP **WILL PAY VIA VENMO APP/PAYPALL** thank you complete the code with unique comments given The game is called Game of Life:
C++ GAME OF LIFE UNIQUE PROJECT HELP **WILL PAY VIA VENMO APP/PAYPALL** thank you complete the code with unique comments given The game is called Game of Life:
C++ GAME OF LIFE UNIQUE PROJECT HELP **WILL PAY VIA VENMO APP/PAYPALL** thank you complete the code with unique comments given The game is called Game of Life:
C++ GAME OF LIFE UNIQUE PROJECT HELP **WILL PAY VIA VENMO APP/PAYPALL** thank you complete the code with unique comments given The game is called Game of Life:

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site