-
Notifications
You must be signed in to change notification settings - Fork 0
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 ae40727
Showing
4 changed files
with
462 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,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> |
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,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); | ||
}); | ||
}); |
Oops, something went wrong.