need help with writing code for conways game of life (c++ linux environment) i h
ID: 642423 • Letter: N
Question
need help with writing code for conways game of life (c++ linux environment)
i have to create a header file, (and a cpp file obviously) and use the driver program given to me:
//life_driver.cpp
//
//This file is a driver program for the Life.cpp module.
//This program must work with your implementations Life.h and Life.cpp
//
#include <iostream>
#include <fstream>
#include "life.h"
const string FILE_NAME = "starting_grid.txt";
using namespace std;
const int NUM_GENERATIONS = 2; //set to a smaller number for debugging
int main() {
populateWorld(FILE_NAME);
showWorld();
for (int iteration = 0; iteration < NUM_GENERATIONS; iteration++) {
//clears screen in Linux
cout << "[2J[1;1H";
iterateGeneration();
showWorld();
}
return 0;
}
-------------------------------------------------------------------------------------
this is what i have so far (what I'm stuck on is the if statements to check the surrounding cells in the int numNeighbor function
Explanation / Answer
#include #include const int gridsize = 75; //Making this a global constant to avoid array issues. void Display(bool grid[gridsize+1][gridsize+1]){ for(int a = 1; aRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.