-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtutorial.html
More file actions
178 lines (162 loc) · 5.08 KB
/
Copy pathtutorial.html
File metadata and controls
178 lines (162 loc) · 5.08 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<html>
<head>
<title>Wireworld</title>
<link rel="stylesheet" type="text/css" href="./styles/style.css">
<script src="./js/utils.js"></script>
<script src="./js/Wireworld.js"></script>
<script src="./js/WireworldCanvas.js"></script>
<audio id="bgmusic" preload="auto" src="./resources/Organoid_-_02_-_Moonlight.mp3" loop="true" autobuffer></audio>
<script>playContinuously("bgmusic");</script>
</head>
<body>
<h1 id="title">Wireworld</h1>
<section class="tutorial">
<p>Welcome to Wireworld. In Wireworld space is discrete. It consists of cells, arranged in a grid.</p>
<div>
<canvas id="ww1"></canvas>
</div>
<p>Cells come in four "states", which are from left to right: Black, Copper, Electron head and Electron tail.</p>
<div>
<canvas id="ww2"></canvas>
<canvas id="ww3"></canvas>
<canvas id="ww4"></canvas>
<canvas id="ww5"></canvas>
</div>
<p>Not only space, but also time is discrete in Wireworld. Although cells never move, they
may change their state from one point in time to the other.</p>
<p>Black cells always stay black.</p>
<div>
<canvas id="ww6"></canvas>
</div>
<p>Electron tails become Copper.</p>
<div>
<canvas id="ww7"></canvas>
</div>
<p>Electron heads become Electron tails.</p>
<div>
<canvas id="ww8"></canvas>
</div>
<p>And finally a cell in Copper state switches to Electron head state if one or two of its
neighbours are in Electron head state.
Copper cells with three or more cells in Electron head state remains in copper state.</p>
<div>
<canvas id="ww9"></canvas>
<canvas id="ww10"></canvas>
</div>
<p>Sounds pretty boring, doesn't it? Let's take a look at the bigger picture.</p>
<div>
<canvas id="ww11"></canvas>
</div>
<p>Keep in mind that movement is illusion in Wireworld!</p>
</section>
<div id="backtomenu"><a href="index.html">Back to Menu</a></div>
<script>
function drawWireworld(cells, id, steps) {
var cellWidth = 30;
var initCells = transpose(cells);
var ww = new Wireworld(cloneRectArray(initCells));
var htmlEl = document.getElementById(id);
htmlEl.width = cellWidth * ww.columns;
htmlEl.height = cellWidth * ww.rows;
var wwc = new WireworldCanvas(ww, htmlEl, htmlEl.width / ww.columns);
wwc.draw();
if (typeof steps !== 'undefined') {
(function animate() {
ww.cells = cloneRectArray(initCells);
wwc.draw();
for (var i=1; i<=steps; i++) {
setTimeout(
function() {ww.doStep(); wwc.draw();},
i*500
);
}
setTimeout(
animate,
(steps+1)*500
);
})();
}
}
//ww1
var cells = [
[0,0,0,0,0,0,0,0,0,0,0,0],
[3,0,0,0,0,0,1,0,0,0,0,0],
[2,0,0,0,0,0,1,0,0,0,0,0],
[1,0,0,0,0,0,1,0,0,0,0,0],
[1,0,0,0,0,0,1,0,0,0,0,0],
[1,0,0,0,0,0,1,0,1,0,0,0],
[1,0,0,0,0,0,0,1,1,1,1,0],
[0,1,1,1,1,1,1,0,1,0,0,0]
];
drawWireworld(cells, 'ww1');
//ww2
cells = [
[0]
];
drawWireworld(cells, 'ww2');
//ww3
cells = [
[1]
];
drawWireworld(cells, 'ww3');
//ww4
cells = [
[2]
];
drawWireworld(cells, 'ww4');
//ww5
cells = [
[3]
];
drawWireworld(cells, 'ww5');
//ww6
cells = [
[0,0,0],
[0,0,0],
[0,0,0]
];
drawWireworld(cells, 'ww6');
//ww7
cells = [
[0,0,0],
[0,3,0],
[0,0,0]
];
drawWireworld(cells, 'ww7', 3);
//ww8
cells = [
[0,0,0],
[0,2,0],
[0,0,0]
];
drawWireworld(cells, 'ww8', 3);
//ww9
cells = [
[0,1,0],
[0,2,0],
[0,0,0]
];
drawWireworld(cells, 'ww9', 3);
//ww10
cells = [
[0,1,0],
[2,2,2],
[0,0,0]
];
drawWireworld(cells, 'ww10', 3);
//ww11
var cells = [
[0,0,0,0,0,0,0,0,0,0,0,0],
[3,0,0,0,0,0,1,0,0,0,0,0],
[2,0,0,0,0,0,1,0,0,0,0,0],
[1,0,0,0,0,0,1,0,0,0,0,0],
[1,0,0,0,0,0,1,0,0,0,0,0],
[1,0,0,0,0,0,1,0,1,0,0,0],
[1,0,0,0,0,0,0,1,1,1,1,0],
[0,1,1,1,1,1,1,0,1,0,0,0]
];
drawWireworld(cells, 'ww11', 21);
</script>
</body>
</html>