-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
74 lines (53 loc) · 1.12 KB
/
main.cpp
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
#include "automaton.h"
#include <ncurses.h>
#include <iostream> //Cout
#include "dieRoll.h" //d4
using namespace std;
void myPrint(vector<bool> vb){
cout << '.';
for (bool b : vb){
cout << b ? '1' : '0';
cout << '.';
}
cout << endl;
}
void duplicateLine(WINDOW* w, int to, int from){
}
void printAutomaton(Automaton& a){
char c;
for (int i = 0; i < a.getSize(); i++){
c = a.read(i) ? 'x' : ' ';
addch(c);
}
}
int main(){
cout << "Rule: ";
int rule;
cin >> rule;
//Init ncurses
initscr(); cbreak(); noecho();
scrollok(stdscr, true);
//Generate Random Config
vector<bool> initialConfig(COLS);
for (int i=0; i<COLS; i++)
initialConfig[i] = bool(d4.roll()%2);
Automaton autocell(rule, initialConfig);
char input = ' ';
move(LINES-1, 0);
bool noPause = false;
while (input != 'q'){
if (input == 'p' ) noPause = !noPause;
nodelay(stdscr, noPause);
refresh();
printAutomaton(autocell);
autocell.tick();
input = getch();
}
endwin();
myPrint(autocell.getRule());
//for (int i = 0; i < 10; i++){
// myPrint(autocell.getConfig());
// autocell.tick();
//}
return 0;
}