CellViz
1.0
src
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
18
class
CellularAutomaton
{
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
27
class
DiscreteAutomaton
:
public
CellularAutomaton
{
28
public
:
29
DiscreteAutomaton
();
30
DiscreteAutomaton
(
int
x,
int
y,
double
value);
31
DiscreteAutomaton
(
const
DiscreteAutomaton
&cell);
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
44
class
ContinuousAutomaton
:
public
CellularAutomaton
{
45
public
:
46
static
void
compute
(
Board
*board);
// Pure virtual function for DiscreteAutomaton
47
};
48
50
51
52
class
ParticleLife
:
public
ContinuousAutomaton
{
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
board.h
BasicLife
Represents a type of cellular automaton called BasicLife.
Definition:
cells.h:73
BasicLife::value
double value
Definition:
cells.h:81
BasicLife::x
int x
Definition:
cells.h:80
Board
Definition:
board.h:21
CellularAutomaton
Definition:
cells.h:18
CellularAutomaton::CellularAutomaton
CellularAutomaton()=default
CellularAutomaton::compute
static void compute(Board *board)
CellularAutomaton::~CellularAutomaton
virtual ~CellularAutomaton()=default
ContinuousAutomaton
Definition:
cells.h:44
ContinuousAutomaton::compute
static void compute(Board *board)
DiscreteAutomaton
Represents a type of cellular automaton called DiscreteAutomaton.
Definition:
cells.h:27
DiscreteAutomaton::x
int x
Definition:
cells.h:40
DiscreteAutomaton::get_x
virtual int get_x()=0
DiscreteAutomaton::value
double value
Definition:
cells.h:41
DiscreteAutomaton::get_y
virtual int get_y()=0
DiscreteAutomaton::get_value
virtual double get_value()=0
ParticleLife
====== END OF ABSTRACT CLASSES ====== ///
Definition:
cells.h:52
ParticleLife::get_species
string get_species()
ParticleLife::x
int x
Definition:
cells.h:68
ParticleLife::species
string species
Definition:
cells.h:69
ParticleLife::ParticleLife
ParticleLife(const ParticleLife &cell)
Definition:
cells.h:58
ParticleLife::y
int y
Definition:
cells.h:68
ParticleLife::get_y
int get_y()
ParticleLife::get_x
int get_x()
SmithLife
Represents a type of cellular automaton called SmithLife.
Definition:
cells.h:85
SmithLife::x
int x
Definition:
cells.h:94
SmithLife::value
double value
Definition:
cells.h:95
Generated by
1.9.1