-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
207 lines (179 loc) · 6.33 KB
/
index.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
<!DOCTYPE html>
<link lang="en">
<meta charset="UTF-8">
<title>Langton's Ant</title>
<link rel="stylesheet" type="text/css" href="css/site.min.css">
<body>
<div class="container param-container">
<div class="container-title">
Simulation Options
</div>
<div>
<label for="initialOrientation">Starting Orientation:</label>
<select id="initialOrientation">
<option value="0">Up</option>
<option value="1">Right</option>
<option value="2">Down</option>
<option value="3">Left</option>
</select>
</div>
<div>
<label for="behaviors">Behavior:</label>
<select id="behaviors">
</select>
</div>
<div class="hide">
<label for="customBehavior">Custom Behavior:</label>
<input id="customBehavior"/>
</div>
<div>
<label for="gridSize">Grid Size:</label>
<select id="gridSize">
<option value="50">50x50</option>
<option value="150" selected>150x150</option>
<option value="250">250x250</option>
<option value="500">500x500</option>
<option value="1000">1000x1000</option>
<option value="5000">5000x5000</option>
</select>
</div>
<div>
<label for="iterations">Steps per Refresh:</label>
<select id="iterations">
<option value="1" selected>1</option>
<option value="10">10</option>
<option value="50">50</option>
<option value="10">100</option>
<option value="250">250</option>
<option value="500">500</option>
<option value="1000">1,000</option>
<option value="5000">5,000</option>
<option value="10000">10,000</option>
<option value="50000">50,000</option>
<option value="100000">100,000</option>
<option value="250000">250,000</option>
<option value="500000">500,000</option>
</select>
</div>
<div>
<label for="delay">Delay per Refresh:</label>
<select id="delay">
<option value="0">1 Millisecond</option>
<option value="50">50 Milliseconds</option>
<option value="250" selected>250 Milliseconds</option>
<option value="500">500 Milliseconds</option>
<option value="1000">1 Second</option>
<option value="2000">2 Seconds</option>
<option value="5000">5 Seconds</option>
</select>
</div>
</div>
<div class="container link-container">
<div class="container-title">
links
</div>
<div>
<a href="https://github.com/coder369/langtons-ant" target="_blank">Source Code (GitHub)</a>
</div>
<div>
<a href="https://en.wikipedia.org/wiki/Langton%27s_ant" target="_blank">Langton's Ant (Wikipedia)</a>
</div>
<div>
<a href="https://en.wikipedia.org/wiki/Christopher_Langton" target="_blank">Christopher Langton (Wikipedia)</a>
</div>
<div>
<a href="https://en.wikipedia.org/wiki/Turing_machine" target="_blank">Turing Machine (Wikipedia)</a>
</div>
<div>
<a href="https://en.wikipedia.org/wiki/Alan_Turing" target="_blank">Alan Turing (Wikipedia)</a>
</div>
</div>
<div>
<div id="displayAntBehavior"></div>
<div>
<span class="step-count">Step Count:</span>
<span id="iterationCount"></span>
</div>
<div>
<canvas id="theBoard"></canvas>
</div>
</div>
<script src="js/moore-sof.langton-ant.min.js"></script>
<script>
var sim = new Simulation();
sim.run();
document.getElementById('initialOrientation').onchange = function () {
sim.Options.setAntOrientation(this.selectedIndex);
sim.run();
};
document.getElementById('behaviors').onchange = function () {
var customBehavior = document.getElementById('customBehavior');
if (this.options.length - 1 == this.selectedIndex) {
customBehavior.value = '';
customBehavior.parentNode.classList.remove('hide');
customBehavior.parentNode.classList.add('show');
sim.reset();
} else {
customBehavior.parentNode.classList.remove('show');
customBehavior.parentNode.classList.add('hide');
sim.Options.setAntBehavior(this.selectedIndex);
sim.run();
}
};
document.getElementById('gridSize').onchange = function () {
sim.Options.setGridSize(this.options[this.selectedIndex].value);
sim.run();
};
document.getElementById('iterations').onchange = function () {
sim.Options.setRefreshInterval(this.options[this.selectedIndex].value);
sim.run();
};
document.getElementById('delay').onchange = function () {
sim.Options.setRefreshDelayInterval(this.options[this.selectedIndex].value);
sim.run();
};
var custbehavior = document.getElementById('customBehavior');
custbehavior.onkeydown = function (e) {
/** Allow the following keys
* 46: delete
* 8: backspace
* 9: tab
* 37: Left-Arrow
* 39: Right-Arrow
* 76: lower-case L
* 82: lower-case R
* 108: Capital L
* 114: Capital R
*/
if (([46, 8, 9, 37, 39, 76, 82, 108, 114].indexOf(e.keyCode) === -1)) {
e.preventDefault();
}
};
custbehavior.onkeyup = function (e) {
if (([46, 8, 9, 37, 39, 76, 82, 108, 114].indexOf(e.keyCode) !== -1)) {
if (this.value.length === 0) {
sim.reset();
} else {
this.value = this.value.toUpperCase();
sim.Options.setCustomAntBehavior(this.value);
sim.run();
}
}
};
</script>
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-56324561-2', 'auto');
ga('send', 'pageview');
</script>
</body>