diff options
| author | Elizabeth Alexander Hunt <me@liz.coffee> | 2026-07-02 11:55:17 -0700 |
|---|---|---|
| committer | Elizabeth Alexander Hunt <me@liz.coffee> | 2026-07-02 11:55:17 -0700 |
| commit | 6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6 (patch) | |
| tree | ed97e39ec77c5231ffd2c394493e68d00ddac5a4 /Homework/cs3460/gameoflife/LifeSimulator.hpp | |
| download | misc-undergrad-6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6.tar.gz misc-undergrad-6bf4b90c90f15f4ab60833bddf5b5756d1a6b1f6.zip | |
Diffstat (limited to 'Homework/cs3460/gameoflife/LifeSimulator.hpp')
| -rw-r--r-- | Homework/cs3460/gameoflife/LifeSimulator.hpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Homework/cs3460/gameoflife/LifeSimulator.hpp b/Homework/cs3460/gameoflife/LifeSimulator.hpp new file mode 100644 index 0000000..38e086b --- /dev/null +++ b/Homework/cs3460/gameoflife/LifeSimulator.hpp @@ -0,0 +1,35 @@ +#include "Pattern.hpp" + +#include <algorithm> +#include <array> +#include <cstdint> +#include <memory> +#include <omp.h> +#include <vector> + +#ifndef LIFESIMULATOR_HPP + #define LIFESIMULATOR_HPP + +class LifeSimulator +{ + private: + std::uint8_t m_width; + std::uint8_t m_height; + + std::vector<std::vector<bool>> m_curr_grid; + std::vector<std::vector<bool>> m_buff_grid; + + std::uint8_t getNeighbors(std::uint8_t x, std::uint8_t y) const; + + public: + LifeSimulator(std::uint8_t sizeX, std::uint8_t sizeY); + + void insertPattern(const Pattern& pattern, std::uint8_t startX, std::uint8_t startY); + void update(); + + std::uint8_t getSizeX() const; + std::uint8_t getSizeY() const; + bool getCell(std::uint8_t x, std::uint8_t y) const; +}; + +#endif // LIFESIMULATOR_HPP |
