forked from aeonstasis/life-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jgm2488-RunLife.c++
130 lines (111 loc) · 2.44 KB
/
jgm2488-RunLife.c++
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// -------------------------
// projects/life/RunLife.c++
// Copyright (C) 2016
// Glenn P. Downing
// -------------------------
// --------
// includes
// --------
#include <cassert> // assert
#include <iostream> // cout, endl
#include "Life.h"
// ----
// main
// ----
int main() {
using namespace std;
// ----------------------
// Life<ConwayCell> 21x13
// ----------------------
cout << "*** Life<ConwayCell> 21x13 ***" << endl;
cout << endl;
/*
Simulate 12 evolutions.
Print every grid (i.e. 0, 1, 2, 3, ... 12)
*/
Life<ConwayCell> l1(cin);
l1.printBoard(cout);
for (int i = 0; i < 12; ++i) {
l1.play();
l1.printBoard(cout);
}
// ----------------------
// Life<ConwayCell> 20x29
// ----------------------
cout << "*** Life<ConwayCell> 20x29 ***" << endl;
cout << endl;
/*
Simulate 28 evolutions.
Print every 4th grid (i.e. 0, 4, 8, ... 28)
*/
Life<ConwayCell> l2(cin);
l2.printBoard(cout);
for (int i = 1; i < 29; i++) {
l2.play();
if (!(i % 4))
l2.printBoard(cout);
}
// -----------------------
// Life<ConwayCell> 109x69
// -----------------------
cout << "*** Life<ConwayCell> 109x69 ***" << endl;
cout << endl;
/*
Simulate 283 evolutions.
Print the first 10 grids (i.e. 0, 1, 2, ... 9).
Print the 283rd grid.
Simulate 40 evolutions.
Print the 323rd grid.
Simulate 2177 evolutions.
Print the 2500th grid.
*/
Life<ConwayCell> l3(cin);
l3.printBoard(cout);
for (int i = 1; i < 10; ++i) {
l3.play();
l3.printBoard(cout);
}
for (int i = 10; i < 284; ++i) {
l3.play();
}
l3.printBoard(cout);
for (int i = 0; i < 40; ++i) {
l3.play();
}
l3.printBoard(cout);
for (int i = 0; i < 2177; ++i) {
l3.play();
}
l3.printBoard(cout);
// -----------------------
// Life<FredkinCell> 20x20
// -----------------------
cout << "*** Life<FredkinCell> 20x20 ***" << endl;
cout << endl;
/*
Simulate 5 evolutions.
Print every grid (i.e. 0, 1, 2, ... 5)
*/
Life<FredkinCell> l4(cin);
l4.printBoard(cout);
for (int i = 0; i < 5; ++i) {
l4.play();
l4.printBoard(cout);
}
// ----------------
// Life<Cell> 20x20
// ----------------
cout << "*** Life<Cell> 20x20 ***" << endl;
cout << endl;
/*
Simulate 5 evolutions.
Print every grid (i.e. 0, 1, 2, ... 5)
*/
Life<Cell> l5(cin);
l5.printBoard(cout);
for (int i = 0; i < 5; ++i) {
l5.play();
l5.printBoard(cout);
}
return 0;
}