-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcell.h
72 lines (54 loc) · 1.73 KB
/
cell.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
/**
* David Mayes
* 150012384
*
* Gavin Henderson
* 150010848
*
* AC21009
* */
#ifndef _CELL_
#define _CELL_
#include <stdio.h>
#include <stdbool.h>
//the cell, points to the cell before and the cell after
typedef struct MyCell{
int data;
struct MyCell* left;
struct MyCell* right;
struct MyCell* up;
struct MyCell* down;
}Cell;
//the cellular automaton has a pointer to the head and the size
typedef struct MyCellGroup{
Cell* head;
struct MyCellGroup* next; //only used in conway
struct MyCellGroup* prev; //" "
int size;
}CellGroup;
//creates a CellGroup takes a int for the size and returns a pointer
CellGroup* createCellGroup(int newValues[], int newGroupSize);
//takes a pointer to a cellgroup and frees its memory
int deleteCellGroup(CellGroup* clgp);
//takes an int, stores it in a Cell and returns a pointer to it
Cell* createCell(int num);
//inserts a cell into the specified group
void insertCell(CellGroup* clgp, Cell* cl);
//takes a pointer to a Cell and free it's memory
int deleteCell(Cell* cl);
//Creates the next generation of the automaton
CellGroup* nextGen(CellGroup* clgp, int* ruleset);
//converts a decimal value to a binary one and returns it
int* binaryConversion(int x);
//Gets the decimal number for the ruleset from the user and validates it
int getUserInput();
//Gets the starting cell group from the user and puts it in a cell group
CellGroup* getInitialGroup();
//prints a cell group
void printCellGroup(CellGroup* clgp);
//Save output to a file
//Takes in the initial cellgroup, ruleset and the number of lines you want to save
void saveOutput(CellGroup* clgp, int* ruleset, int lines);
//Delays the program for a set number of seconds
void delay(unsigned int seconds);
#endif //_CELL_