0% found this document useful (0 votes)
112 views

C++ Game of Life Header File

This document defines a Life class that represents John Conway's Game of Life simulation. The Life class contains methods to count each cell's neighbors, generate the next generation, print the map, run a random or file-based simulation, and check for stability or an empty map. Private members track the grid dimensions and generation count, as well as flags and arrays to manage the current and next maps.

Uploaded by

Kurt Nguyen
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as EHTML, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views

C++ Game of Life Header File

This document defines a Life class that represents John Conway's Game of Life simulation. The Life class contains methods to count each cell's neighbors, generate the next generation, print the map, run a random or file-based simulation, and check for stability or an empty map. Private members track the grid dimensions and generation count, as well as flags and arrays to manage the current and next maps.

Uploaded by

Kurt Nguyen
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as EHTML, PDF, TXT or read online on Scribd
You are on page 1/ 1

#ifndef Life_H #define Life_H #include <iostream> #include <fstream> #include <ctime> #include <cstdlib> #include <string.

h> #include "Cell.h" #include <limits> #include <unistd.h> class Life { public: Life(); virtual ~Life(); void count_neighbors(); void count_neighbors(Cell* c); void next_generation(); void print_map(); void menu(); bool map_is_empty(); bool map_is_stable(); void random_map(int r, int c, float dens); void file_map(std::string nowname); void run_sim(); private: unsigned int col, row, bound, generation, run_config; float density; Cell*** now; Cell*** next; std::ofstream outf; bool stable, file_good; }; #endif

You might also like