-
Notifications
You must be signed in to change notification settings - Fork 7
/
gameOfLife.html
70 lines (70 loc) · 2.68 KB
/
gameOfLife.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
<!DOCTYPE html>
<html>
<head>
<title>Conway's Game Of Life... 3D!</title>
<meta name="author" content="Samuel Levy" />
<script type="text/javascript" src="RequestAnimationFrame.js"></script>
<script type="text/javascript" src="three.js/build/Three.js"></script>
<script type="text/javascript" src="jquery-1.7.min.js"></script>
<script type="text/javascript" src="gameoflife.js" defer="defer"></script>
<style>
body {
font-family: Monospace;
background-color: #f0f0f0;
margin: 0px;
padding: 10px;
}
</style>
</head>
<body>
<h1>Conway's Game Of Life... Now in 3D!</h1>
<p>
Conway's Game of life is... well it's <a href="http://www.bitstorm.org/gameoflife/">this</a>.
Obviously, it's pretty two dimensional, and that implementation is very
"written in java". Now there's all this fun "HTML5" stuff like canvases and
the like, so I figure that it's about time I figure out how they work.
</p>
<p>
Now, of course, with the extra dimension, the math will have to change.
Experiment time!
</p>
<p>
<strong>Rules:</strong>
<ul>
<li>Cells (in this case, cubes) with only 1 or less neighbours die, as if by lonliness.</li>
<li>If 5 cells surround an empty cell, they breed and fill it.</li>
<li>If a cell has 8 or more neighbours, it dies from overcrowding.</li>
</ul>
</p>
<div id="gameoflife" style="border:1px solid #CCCCCC; margin:20px;"></div>
<div id="controls">
Map size:
<select name="size" id="size">
<option value="10">Tiny (1000 cells)</option>
<option value="20">Small (8000 cells)</option>
<option value="25">Medium (15625 cells)</option>
<option value="30">Big (27000 cells)*</option>
<option value="50">Massive (125000 cells)*</option>
</select>
Speed:
<select name="speed" id="speed">
<option value="1000">Slow (1 generation/second)</option>
<option value="500">Medium (2 generations/second)</option>
<option value="100">Fast (10 generations/second)</option>
<option value="50">Hyper (20 generations/second)</option>
</select>
<input type="button" id="pause" value="Stop" />
<input type="button" id="reset" value="Randomize/Reset" />
</div>
<p>
This was a fun experiment, created by <a href="http://www.samuellevy.com/">Samuel Levy</a>.
You can get the source code on <a href="https://github.com/samlev/3DGameOfLife">Git Hub</a>.
</p>
<p>
I used <a href="http://jquery.com/">jQuery</a>, <a href="https://github.com/mrdoob/three.js/">Three.js</a>,
and <a href="http://paulirish.com/2011/requestanimationframe-for-smart-animating/">RequestAnimationFrame</a>
to build this.
</p>
<p>* May be very slow... use at your own risk</p>
</body>
</html>