-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsand.html
556 lines (543 loc) · 26.5 KB
/
sand.html
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
<!DOCTYPE html>
<!--
TODO:
Move the "Selected Pile" feature into the canvas that hovers just north of the cursor
-->
<head>
<link rel="icon" type="image/png" href="sand.png">
</head>
<body oncontextmenu="return false">
<canvas id="conway" height=948 width=1398></canvas>
<div id="player">
<text class="left">PLAYER</text>
<text class="right">CANVAS</text><br>
<button class="left player" id="pause" onclick="ruleChange(0); blur()" title="Start the engine" oncontextmenu="blur()">PLAY</button>
<button class="right player" onclick="random(); blur()" title="Randomize the activity of every cell in the canvas" oncontextmenu="blur()">RANDOM</button><br>
<button class="left player" onclick="table.frame = true; blur()" title="Generate the next frame (engine must be paused)" oncontextmenu="blur()">TOPPLE</button>
<button class="right player" id="clear" onclick="blur()" title="Set all cells to inactive" oncontextmenu="blur()">CLEAR</button><br>
<button class="speed button" id="speed" onclick="blur()" title="Set how many frames per second (FPS) the engine runs in" oncontextmenu="blur()" disabled>60 FPS</button>
<input class="slider" id="slide1" onclick="blur()" oninput="ruleChange(1);" type="range" min="10" max="100" value="60"><br><br>
<text class="left">TOTAL SAND</text>
<button class="right" id="count" title="Active Cells" oncontextmenu="blur()" disabled>0</button><br>
<text class="left">LARGEST PILE</text>
<button class="right" id="largest" title="Largest amount of sand in one cell" oncontextmenu="blur()" disabled>0</button><br>
<text class="left">SELECTED PILE</text>
<button class="right" id="hovered" title="Amount of sand in the cell under your cursor" oncontextmenu="blur()" disabled>0</button><br><br>
<button class="speed button" id="size" onclick="blur()" title="How much sand is added or removed from a pile when left- or right-clicked" oncontextmenu="blur()" disabled>PEN SIZE: 4</button><br>
<input class="slider" id="slide2" onclick="blur()" oninput="ruleChange(6);" type="range" min="1" max="256" value="4"><br><br>
<text class="middle">TOPPLE RULES</text><br>
<button class="middle setting nocolor" id="topple" onclick="ruleChange(7); blur()" oncontextmenu="ruleChange(8); blur()" title="When a pile has as much or more sand than it has neighbors, it topples, giving one sand to each of its neighbors.">NORMAL</button><br>
<button class="middle setting nocolor" id="neighbor" onclick="ruleChange(9); blur()" oncontextmenu="ruleChange(10); blur()" title="Neighboring pile configuration Topple threshhold: 4"></button><br><br>
<button class="left setting false" id="wrap" onclick="ruleChange(2); blur()" oncontextmenu="blur()" title="Cells ignore the canvas borders and are able to affect cells on the opposite edge">WRAP</button>
<button class="middle setting false" id="grid" onclick="ruleChange(5); blur()" oncontextmenu="blur()" title="All cells have a light border around them">GRID</button>
<button class="right setting nocolor" id="color" onclick="ruleChange(3); blur()" oncontextmenu="ruleChange(4); blur()" title="Change the color of piles based on size">COLOR</button>
</div>
</body>
<html>
<title>Sand Pile Engine - hover over buttons for a description of what they do</title>
<style>
body { user-select: none; }
button {
background-color: #8ee;
border-color: #7cc;
border-radius: 5px;
color: #000;
font-size: 28px;
height: 38px;
cursor: pointer;
outline: none; }
canvas {
border-width: 2px;
border-style: outset;
border-color: #abc;
border-radius: 3px; }
#activeCount {
background-color: #000;
border-color: #666;
color: #fff;
width: 100px; }
#color.dark {
background-image: linear-gradient(to right, #eee, #000);
color: #fff; }
#color.invert {
background-color: #fff;
color: #000; }
#color.darkinvert {
background-image: linear-gradient(to left, #eee, #000);
color: #fff; }
#color.redlight {
background-image: linear-gradient(to right, #fdd, #f00, #000);
color: #fff; }
#color.reddark {
background-image: linear-gradient(to right,#f00, #000);
color: #fff; }
#color.redlightinvert {
background-image: linear-gradient(to left, #fdd, #f00);
color: #fff; }
#color.reddarkinvert {
background-image: linear-gradient(to left,#f00, #000);
color: #fff; }
#color.greenlight {
background-image: linear-gradient(to right, #dfd, #0f0, #000);
color: #fff; }
#color.greendark {
background-image: linear-gradient(to right,#0f0, #000);
color: #fff; }
#color.greenlightinvert {
background-image: linear-gradient(to left, #dfd, #0f0);
color: #fff; }
#color.greendarkinvert {
background-image: linear-gradient(to left,#0f0, #000);
color: #fff; }
#color.bluelight {
background-image: linear-gradient(to right, #ddf, #00f, #000);
color: #fff; }
#color.bluedark {
background-image: linear-gradient(to right,#00f, #000);
color: #fff; }
#color.bluelightinvert {
background-image: linear-gradient(to left, #ddf, #00f);
color: #fff; }
#color.bluedarkinvert {
background-image: linear-gradient(to left,#00f, #000);
color: #fff; }
#color.nocolor {
background-color: #000;
color: #fff; }
#color.rainbow {
background-image: linear-gradient(to right, #f00, #aa0, #0f0, #0aa, #00f, #808, #000);
color: #fff; }
#color.rainbowInvert {
background-image: linear-gradient(to right, #808, #00f, #0aa, #0f0, #aa0, #f00, #000);
color: #fff; }
#dotCount { background-image: linear-gradient(to right, #111, #fff); }
#neighbor {
width: 50px;
height: 50px;
background-image: url("sand/hood1.png");
background-size: cover;
}
#player {
position: fixed;
top: 8px;
left: 1417px;
width: 400px;
text-align: center;
line-height: 40px;
font-size: 200%; }
#sandCount {
background-color: rgb(240, 220, 100);
border-color: rgb(220, 200, 80) }
#size { width: 225px; }
#slide1 { width: 250px; }
#slide2 { width: 350px; }
#topple { width: 150px; }
.activation {
background-color: #789;
width: 120px;
height: 162px;
border-radius: 5px 5px 4px 4px; }
.activation > .setting {
position: relative;
top: -3px; }
.activation > .rule {
position: relative;
top: -3px;
width: 38px;
margin: 1px -3px 0px -3px; }
.false { background-color: #dc143c; }
.left {
position: absolute;
left: 0px; }
.middle {
position: relative;
right: 4px;
bottom: 3px; }
.player {
width: 140px;
text-align: center; }
.right {
position: absolute;
right: 8px; }
.setting {
padding: 0px;
white-space: nowrap;
width: 120px; }
.slider {
-webkit-appearance: none;
height: 15px;
border-radius: 5px;
background: #d3d3d3;
outline: none;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 25px;
height: 25px;
background: #8ee;
border-color: #f00;
border-width: 2px;
border-radius: 5px;
cursor: pointer;
}
.speed { width: 125px; }
.true { background-color: #7fff00; }
</style>
<script>
var convas = document.getElementById("conway");
var ctx = convas.getContext("2d");
var table = {
birth: [false, false, false, true, false, false, false, false, false],
board: [],
color: 0,
cursor: false,
death: [true, true, false, false, true, true, true, true, true],
drawType: 0,
grid: false,
neighbor: 0,
paused: true,
size: 4,
speed: 60,
topple: 0,
wrap: false
}
var RGBs = {
apricot: [255, 192, 128],
blue: [0, 0, 255],
brown: [128, 64, 0],
chartreuse: [128, 208, 0],
copper: [192, 128, 0],
cyan: [0, 224, 224],
darkBlue: [0, 0, 128],
gold: [255, 208, 0],
green: [0, 128, 0],
indigo: [64, 0, 192],
lightBlue: [128, 128, 255],
lime: [128, 255, 0],
magenta: [255, 0, 255],
maroon: [192, 0, 64],
orange: [255, 128, 0],
pink: [255, 128, 208],
purple: [128, 0, 128],
red: [255, 0, 0],
scarlet: [255, 64, 0],
silver: [192, 192, 208],
teal: [0, 128, 128],
violet: [64, 0, 192],
yellow: [255, 255, 0]
}
draw = () => {
let data = ctx.getImageData(0, 0, 1398, 948);
for (let y = 158; y--;)
{
for (let x = 233; x--;)
{
let pile = table.board[y][x];
for (let i = 0; i < 36; i++)
{
data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 3] = 255;
let r, g, b;
if (pile == 0)
[r, g, b] = [255, 255, 255];
else if (pile >= [4, 8, 8, 12, 20, 24][table.neighbor])
[r, g, b] = [0, 0, 0];
else
[r, g, b] = RGBs[[
"red green blue yellow cyan magenta orange teal gold silver copper lime indigo scarlet purple chartreuse maroon violet brown pink lightBlue apricot darkBlue".split(' '),
"blue brown chartreuse copper cyan darkBlue darkRed gold green indigo lightBlue lime magenta maroon orange pink purple red scarlet silver teal violet yellow".split(' ')
][table.color][pile - 1]];
data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 0] = r;
data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 1] = g;
data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 2] = b;
if (table.grid)
if (i < 6 || i > 29 ||i % 6 == 0 || i % 6 == 5)
{
data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 0] += 100;
data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 1] += 100;
data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 2] += 100;
data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 3] = 255;
data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 0] /= 2;
data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 1] /= 2;
data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 2] /= 2;
}
if (table.cursor && (
(x == table.cursor[0] + 1 && y == table.cursor[1] && i % 6 < 2) ||
(x == table.cursor[0] - 1 && y == table.cursor[1] && i % 6 > 3) ||
(y == table.cursor[1] + 1 && x == table.cursor[0] && i < 12) ||
(y == table.cursor[1] - 1 && x == table.cursor[0] && i > 23) ||
(x == table.cursor[0] + 1 && y == table.cursor[1] + 1 && i == 0) ||
(x == table.cursor[0] - 1 && y == table.cursor[1] + 1 && i == 5) ||
(x == table.cursor[0] + 1 && y == table.cursor[1] - 1 && i == 30) ||
(x == table.cursor[0] - 1 && y == table.cursor[1] - 1 && i == 35)))
{
data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 0] = pile > 0 ? 255 - data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 0] : 0;
data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 1] = pile > 0 ? 255 - data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 1] : 0;
data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 2] = pile > 0 ? 255 - data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 2] : 0;
data.data[((y * 6 + (i / 6 | 0)) * 1398 + (x * 6 + (i % 6))) * 4 + 3] = 255;
}
}
}
}
let count = 0;
let largest = 0;
let hovered = 0;
for (let y = 0; y < 158; y++)
for (let x = 0; x < 233; x++)
{
count += table.board[y][x];
if (table.board[y][x] > largest)
largest = table.board[y][x];
if (table.cursor && table.cursor[0] == x && table.cursor[1] == y)
hovered = table.board[y][x];
}
document.getElementById("count").innerText = count;
document.getElementById("largest").innerText = largest;
document.getElementById("hovered").innerText = hovered;
ctx.putImageData(data, 0, 0);
}
random = () => {
table.board = [];
for (let y = 158; y--;)
{
let a = [];
for (let x = 233; x--;)
{
let b = Math.random() * 5 | 0;
a.push(b);
}
table.board.push(a);
}
}
clear = () => {
table.board = [];
for (let y = 158; y--;)
{
let a = [];
for (let x = 233; x--;)
a.push(0);
table.board.push(a);
}
}
start = () => {
table.board = [];
for (let y = 0; y < 158; y++)
{
let Y = [];
for (let x = 0; x < 233; x++)
Y.push(0);
table.board.push(Y);
}
table.board[78][116] = 2 ** 2 ** 2 ** 2;
}
topple = () => {
if (!table.paused || table.frame)
{
table.frame = false;
let clone = [];
ctx.scale(1 / 3, 1 / 3);
for (let y = 0; y < 158; y++)
{
let Y = [];
for (let x = 0; x < 233; x++)
{
Y.push(0);
}
clone.push(Y);
}
for (let y = 0; y < 158; y++)
{
for (let x = 0; x < 233; x++)
{
let Z = [4, 8, 8, 12, 20, 24][table.neighbor];
if (table.board[y][x] >= Z)
{
if (table.topple == 0)
{
amount = 1;
clone[y][x] += table.board[y][x] - Z;
}
if (table.topple == 1 && table.board[y][x] == Z)
{
amount = 1;
clone[y][x] += table.board[y][x] - Z;
}
if (table.topple == 1 && table.board[y][x] > Z)
{
amount = table.board[y][x] / (Z + 1) | 0;
clone[y][x] += (table.board[y][x] % (Z + 1)) + amount;
}
if (table.topple == 2)
{
amount = table.board[y][x] / Z | 0;
clone[y][x] += table.board[y][x] % Z;
}
let cells = [
[[-1, 0], [0, 1], [1, 0], [0, -1]],
[[-1, 0], [0, 1], [1, 0], [0, -1], [1, 1], [1, -1], [-1, 1], [-1, -1]],
[[-1, 0], [0, 1], [1, 0], [0, -1], [-2, 0], [0, 2], [2, 0], [0, -2]],
[[-1, 0], [0, 1], [1, 0], [0, -1], [1, 1], [1, -1], [-1, 1], [-1, -1], [-2, 0], [0, 2], [2, 0], [0, -2]],
[[-1, 0], [0, 1], [1, 0], [0, -1], [1, 1], [1, -1], [-1, 1], [-1, -1], [-2, 0], [0, 2], [2, 0], [0, -2], [-2, 1], [-2, -1], [2, 1], [2, -1], [1, 2], [-1, 2], [1, -2], [-1, -2]],
[[-1, 0], [0, 1], [1, 0], [0, -1], [1, 1], [1, -1], [-1, 1], [-1, -1], [-2, 0], [0, 2], [2, 0], [0, -2], [-2, 1], [-2, -1], [2, 1], [2, -1], [1, 2], [-1, 2], [1, -2], [-1, -2], [2, 2], [2, -2], [-2, 2], [-2, -2]] ][table.neighbor];
for (d = 0; d < Z; d++)
{
let Y = y + cells[d][0];
let X = x + cells[d][1];
if (Y < 0 && !table.wrap) continue;
if (Y > 157 && !table.wrap) continue;
if (X < 0 && !table.wrap) continue;
if (X > 232 && !table.wrap) continue;
if (Y < 0 && table.wrap) Y += 158;
if (Y > 157 && table.wrap) Y -= 158;
if (X < 0 && table.wrap) X += 233;
if (X > 232 && table.wrap) X -= 233;
clone[Y][X] += amount;
}
}
else
clone[y][x] += table.board[y][x];
}
}
table.board = clone;
}
draw();
setTimeout(() => topple(), 1000 / table.speed);
}
ruleChange = (rule) => {
let ruleNames = ["NORMAL", "EVENLY", "FAST"];
let ruleDescs = [
"When a pile has as much or more sand than\nit has neighbors, it topples, giving one sand\nto each of its neighbors.",
"When a pile has as much sand as it has neighbors,\nit topples, giving one sand to each of its\nneighbors.\n\nWhen a pile has more sand than it has neighbors,\nit topples, distributing all of its sand evenly\nbetween itself and its neighbors.",
"When a pile has as much or more sand than\nit has neighbors, it topples, distributing all\nof its sand evenly between its neighbors."
];
let toppleThreshholds = [4, 8, 8, 12, 20, 24];
switch (rule)
{
case 0:
pause = document.getElementById("pause");
table.paused = !table.paused;
if (table.paused)
{
pause.innerText = "PLAY";
pause.title = "Start the engine";
}
else
{
pause.innerText = "PAUSE";
pause.title = "Stop the engine";
}
break;
case 1: // SPEED
table.speed = document.getElementById("slide1").value;
document.getElementById("speed").innerText = table.speed + " FPS";
break;
case 2: // WRAP
let wrap = document.getElementById("wrap");
table.wrap = !table.wrap;
wrap.classList.remove(!table.wrap);
wrap.classList.add(table.wrap);
break;
case 3: // COLOR NEXT
break;
case 4: // COLOR PREV
break;
case 5: // GRID
let grid = document.getElementById("grid");
table.grid = !table.grid;
grid.classList.remove(!table.grid);
grid.classList.add(table.grid);
break;
case 6: // PEN SIZE
table.size = document.getElementById("slide2").value;
document.getElementById("size").innerText = "PEN SIZE: " + table.size;
break;
case 7: // TOGGLE TOPPLE CHANGE FORWARDS
table.topple = table.topple == 2 ? 0 : table.topple + 1;
document.getElementById("topple").innerText = ruleNames[table.topple];
document.getElementById("topple").title = ruleDescs[table.topple];
break;
case 8: // TOGGLE TOPPLE CHANGE BACKWARDS
table.topple = table.topple == 0 ? 2 : table.topple - 1;
document.getElementById("topple").innerText = ruleNames[table.topple];
document.getElementById("topple").title = ruleDescs[table.topple];
break;
case 9: // TOGGLE NEIGHBOR CHANGE FORWARDS
table.neighbor = table.neighbor == 5 ? 0 : table.neighbor + 1;
document.getElementById("neighbor").style.backgroundImage = `url("sand/hood${table.neighbor + 1 }.png")`;
document.getElementById("neighbor").title = "Neighboring pile configuration\nTopple threshhold: " + toppleThreshholds[table.neighbor];
break;
case 10: // TOGGLE NEIGHBOR CHANGE BACKWARDS
table.neighbor = table.neighbor == 0 ? 5 : table.neighbor - 1;
document.getElementById("neighbor").style.backgroundImage = `url("sand/hood${table.neighbor + 1 }.png")`;
document.getElementById("neighbor").title = "Neighboring pile configuration\nTopple threshhold: " + toppleThreshholds[table.neighbor];
break;
}
}
document.getElementById("clear").addEventListener("click", () => clear());
document.addEventListener("keydown", (e) => {
switch (e.key)
{
case " ": ruleChange(0);
}
});
convas.addEventListener("mousemove", (e) => {
findxy('move', e)
}, false);
convas.addEventListener("mousedown", (e) => {
findxy('down', e);
blur();
}, false);
convas.addEventListener("mouseup", (e) => {
findxy('up', e)
}, false);
convas.addEventListener("mouseout", (e) => {
findxy('out', e)
}, false);
findxy = (res, e) => {
if (res == 'down') {
let prevX = table.cursor[0];
let prevY = table.cursor[1];
let currX = e.offsetX / 6 | 0;
let currY = e.offsetY / 6 | 0;
table.drawType = e.button == 0 ? 1 : -1;
table.board[currY][currX] += (table.drawType == 1 ? table.size : table.size > table.board[currY][currX] ? -table.board[currY][currX] : -table.size) * 1;
table.flag = true;
table.cursor = [currX, currY];
draw();
}
if (res == 'up' || res == "out") {
table.flag = false;
table.cursor = false;
}
if (res == 'move') {
let prevX = table.cursor[0];
let prevY = table.cursor[1];
let currX = e.offsetX / 6 | 0;
let currY = e.offsetY / 6 | 0;
table.cursor = [currX, currY];
if (table.flag && (prevX != currX || prevY != currY))
{
let dir = Math.abs(prevX - currX) >= Math.abs(prevY - currY) ? 0 : 1;
let dis = dir == 0 ? Math.abs(prevX - currX) : Math.abs(prevY - currY);
let slope = Math.abs(((currY - prevY) / (currX - prevX)));
for (let i = 0; i < dis; i++)
{
let Y, X;
if (dir == 0)
Y = currY - Math.round(i * slope * (prevY > currY ? -1 : 1)),
X = currX - (i * (prevX > currX ? -1 : 1));
if (dir == 1 && slope == Infinity)
Y = currY - (i * (prevY > currY ? -1 : 1)),
X = currX;
if (dir == 1 && slope != Infinity)
Y = currY - (i * (prevY > currY ? -1 : 1)),
X = currX - Math.round(i * (1 / slope) * (prevX > currX ? -1 : 1));
table.board[Y][X] += (table.drawType == 1 ? table.size : table.size > table.board[Y][X] ? -table.board[Y][X] : -table.size) * 1;
}
}
}
}
start();
topple();
</script>
</html>