CellViz  1.0
cells.h
Go to the documentation of this file.
1 //
2 // Created by velocitatem on 9/27/24.
3 //
4 
5 #include <string>
6 #ifndef CELLS_H
7 #define CELLS_H
8 #include <nlohmann/json.hpp>
9 
10 
11 #include "board.h"
12 
13 class Board;
14 using namespace std;
15 
16 
17 // this is our code abstraction for the cells
19 public:
20 protected:
21  CellularAutomaton() = default;
22  static void compute(Board *board); // Make compute a pure virtual function
23 public:
24  virtual ~CellularAutomaton() = default;
25 };
26 
28 public:
30  DiscreteAutomaton(int x, int y, double value);
32  virtual double get_value() = 0;
33  virtual int get_x() = 0;
34  virtual int get_y() = 0;
35  void set_x(int x);
36  void set_y(int y);
37  void set_value(double value);
38  bool operator==(const DiscreteAutomaton &cell) const;
39 private:
40  int x, y;
41  double value;
42 };
43 
45 public:
46  static void compute(Board *board); // Pure virtual function for DiscreteAutomaton
47 };
48 
50 
51 
53 public:
54  // 3 main constructors
55  ParticleLife();
56  ParticleLife(int x, int y, string species); //TODO: Color
57  // copy
58  ParticleLife(const ParticleLife &cell) {
59  x = cell.x;
60  y = cell.y;
61  species = cell.species;
62  }
63  int get_x();
64  int get_y();
65  string get_species();
66  static Board compute(Board *board);
67 private:
68  int x, y;
69  string species;
70 };
71 
72 
73 class BasicLife : public DiscreteAutomaton {
74 public:
75  BasicLife(int x, int y, double value);
76  int get_x(); int get_y();
77  double get_value();
78  static void compute(Board *board);
79 private:
80  int x, y;
81  double value;
82 };
83 
84 
85 class SmithLife : public DiscreteAutomaton {
86 public:
87  SmithLife(int x, int y, double value);
88  ~SmithLife();
89  int get_x(); int get_y();
90  double get_value();
91  void set_value(double value);
92  static void compute(Board &board);
93 private:
94  int x, y;
95  double value;
96 
97 };
98 
99 
100 #endif //CELLS_H
Represents a type of cellular automaton called BasicLife.
Definition: cells.h:73
double value
Definition: cells.h:81
int x
Definition: cells.h:80
Definition: board.h:21
Definition: cells.h:18
CellularAutomaton()=default
static void compute(Board *board)
virtual ~CellularAutomaton()=default
Definition: cells.h:44
static void compute(Board *board)
Represents a type of cellular automaton called DiscreteAutomaton.
Definition: cells.h:27
int x
Definition: cells.h:40
virtual int get_x()=0
double value
Definition: cells.h:41
virtual int get_y()=0
virtual double get_value()=0
====== END OF ABSTRACT CLASSES ====== ///
Definition: cells.h:52
string get_species()
int x
Definition: cells.h:68
string species
Definition: cells.h:69
ParticleLife(const ParticleLife &cell)
Definition: cells.h:58
int y
Definition: cells.h:68
Represents a type of cellular automaton called SmithLife.
Definition: cells.h:85
int x
Definition: cells.h:94
double value
Definition: cells.h:95