-
Notifications
You must be signed in to change notification settings - Fork 0
/
eca.h
83 lines (54 loc) · 1.29 KB
/
eca.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
eca.h
Copyright (c) 2018 andynines
MIT License
*/
#ifndef ECA_H
#define ECA_H
// Includes
#include <limits.h>
#include <stdbool.h>
// Constants
#define BLOCK_BYTES (sizeof(CellBlock))
#define BLOCK_BITS (BLOCK_BYTES * CHAR_BIT)
// Data types
typedef enum {
// Represent the available ways of spacing alive cells
EVEN,
RANDOM
} SpacingCode;
typedef struct {
// Represent different configurations for generation initializer
int aliveReq;
SpacingCode spacing;
} ConfigCode;
typedef enum {
// Specifies how boundaries are treated
WRAP,
DEAD_BORDERS,
ALIVE_BORDERS
} BoundaryCode;
typedef unsigned short int CellBlock;
typedef struct {
CellBlock* blockArr;
} Generation;
typedef struct {
int age;
int rule;
int habitatSize;
int genBufferSize;
int blockReq;
BoundaryCode borderType;
ConfigCode initCode;
Generation* genArr;
} Simulation;
// Function declarations
Simulation* createSim(int rule,
int habitatSize,
int genBufferSize,
BoundaryCode borderType,
ConfigCode initCode);
bool getCellState(CellBlock* intlBlockPtr, int cellIndex);
void iterateSim(Simulation* simPtr, int iterations);
void destroySim(Simulation* simPtr);
#endif