Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4c8ded0
Showing
6 changed files
with
590 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
div{ | ||
margin: 5px 0 5px 0; | ||
} | ||
|
||
label{ | ||
display: inline-block; | ||
width: 150px; | ||
text-align: right; | ||
} | ||
select{ | ||
width: 150px; | ||
} | ||
input{ | ||
width: 146px; | ||
} | ||
|
||
.container{ | ||
position: relative; | ||
border: 1px solid #aaa; | ||
border-radius: 3px; | ||
margin: 10px 10px 10px 0; | ||
padding: 25px 20px 5px 25px; | ||
background-color: #f4f4f4; | ||
float: left; | ||
} | ||
|
||
.container-title{ | ||
position: absolute; | ||
top:0; | ||
left:5px; | ||
font-weight: bold; | ||
} | ||
|
||
#displayAntBehavior{ | ||
clear: both; | ||
} | ||
|
||
.behavior{ | ||
display:inline-block; | ||
width:24px; | ||
height:24px; | ||
margin: 0 5px 5px 0; | ||
border:1px solid #aaa; | ||
vertical-align: middle; | ||
border-radius: 3px; | ||
overflow: hidden; | ||
} | ||
|
||
.step-count{ | ||
width:100%; | ||
height:24px; | ||
vertical-align: middle; | ||
} | ||
|
||
#iterationCount{ | ||
width:100%; | ||
height:24px; | ||
font: 20px arial, sans-serif; | ||
color: #000; | ||
vertical-align: middle; | ||
|
||
} | ||
|
||
.show{ | ||
display: block; | ||
overflow: visible; | ||
} | ||
|
||
.hide{ | ||
display: none; | ||
overflow: hidden; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
<!DOCTYPE html> | ||
<link lang="en"> | ||
<meta charset="UTF-8"> | ||
<title>Langton's Ant</title> | ||
|
||
<link rel="stylesheet" type="text/css" href="css/site.css"> | ||
<body> | ||
<div> | ||
<a href="http://www.mooresof.com" target="_blank">My Resume</a> | ||
</div> | ||
<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="10000">100000x10000</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> | ||
</select> | ||
</div> | ||
<div> | ||
<label for="delay">Delay per Refresh:</label> | ||
<select id="delay"> | ||
<option value="0" selected>1 Millisecond</option> | ||
<option value="50">50 Milliseconds</option> | ||
<option value="250">250 Milliseconds</option> | ||
<option value="500">500 Milliseconds</option> | ||
<option value="1000">1 Second</option> | ||
<option value="2000">2 Seconds</option> | ||
</select> | ||
</div> | ||
</div> | ||
<div class="container link-container"> | ||
<div class="container-title"> | ||
links | ||
</div> | ||
<div> | ||
<a href="https://en.wikipedia.org/wiki/Cellular_automaton" target="_blank">Cellular Automaton (Wikipedia)</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.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> |
Oops, something went wrong.