Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rdsilver committed Dec 10, 2015
0 parents commit ae40727
Show file tree
Hide file tree
Showing 4 changed files with 462 additions and 0 deletions.
39 changes: 39 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<html>
<head>
<meta charset="UTF-8">
<script language="javascript" type="text/javascript" src="http://p5js.org/js/p5.min.js"></script>
<script src="http://peterolson.github.com/BigInteger.js/BigInteger.min.js"></script>
<script language="javascript" type="text/javascript" src="sketch.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="selecting_neighbors.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
<div id="sketch"></div>
<div id="Info">
<p>Info</p>
<p id='cells_alive'>% Cells Alive : </p>
<p id='cells_dead'>% Cells Dead : </p>
<p id='generations'>Generations : </p>
<p><a href="https://en.wikipedia.org/wiki/Cellular_automaton">What is even going on?</a></p>
</div>
<div id="neighborhood">
<p>Neighborhood</p>
<table>
<tr><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td><td></td><td></td></tr>
<tr><td></td><td></td><td></td><td></td><td></td></tr>
</table>
</div>
<div id="controls">
<p>Click on grid to inverse cell state</p>
<p>N - New Rule</p>
<p>R - Restart Current Rule</p>
<p>S - Scramble Current Rule</p>
<p>Click cells to include in neighborhood</p>
</div>
</body>
</html>
33 changes: 33 additions & 0 deletions selecting_neighbors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
$(function() {

$('#neighborhood').attr("data-neighbors", pad(baseConvert(HashString['n'], 63, 2), 25));
var vals = $('#neighborhood').data('neighbors');
$('#neighborhood td').each( function(index, element){
if (vals[index] == 1)
$(this).addClass("selected");
});

$('#neighborhood td').click(function() {
if(!$(this).hasClass("selected")) {
if($('#neighborhood td.selected').length == 9) {
alert('Max of 8 classes, this is for your own good trust me :)')
return;
}
$(this).addClass("selected");
}
else
$(this).removeClass("selected");

var new_neighbor_string = '';
$('#neighborhood td').each( function(index, element){
if($(this).hasClass("selected"))
new_neighbor_string += '1'
else
new_neighbor_string += '0'
});

// Set the new hash and set the new neighboorhood in the sketch
$('#neighborhood').attr("data-neighbors", pad(baseConvert(new_neighbor_string, 63, 2), 25));
set_new_neighborhood_and_rules(new_neighbor_string);
});
});
Loading

0 comments on commit ae40727

Please sign in to comment.