disinclined.org
/
git
/
cellular-automaton.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
22824bd
)
created populate function to seed from serialize
master
author
Dylan Lloyd
<dylan@dylansserver.com>
Thu, 27 Dec 2012 06:11:41 +0000
(
01:11
-0500)
committer
Dylan Lloyd
<dylan@dylansserver.com>
Thu, 27 Dec 2012 06:11:41 +0000
(
01:11
-0500)
2d.js
patch
|
blob
|
history
diff --git
a/2d.js
b/2d.js
index
c3a4bbe
..
2e731c9
100644
(file)
--- a/
2d.js
+++ b/
2d.js
@@
-77,14
+77,25
@@
$(document).ready(function(){
}
this.serialize = function() {
}
this.serialize = function() {
- var serial =
''
;
+ var serial =
[]
;
for (var i = 0; i < this.rows; i++) {
for (var i = 0; i < this.rows; i++) {
+ var row = [];
for (var ii = 0; ii < this.columns; ii++) {
for (var ii = 0; ii < this.columns; ii++) {
-
serial +
= this.population[i][ii].state;
+
row[ii]
= this.population[i][ii].state;
}
}
+ serial.push(row);
}
return serial;
}
}
return serial;
}
+
+ this.populate = function(seed) {
+ for (var i = 0; i < this.rows; i++) {
+ for (var ii = 0; ii < this.columns; ii++) {
+ seed[i][ii] ? this.population[i][ii].revive()
+ : this.population[i][ii].kill();
+ }
+ }
+ }
}
function tick(automaton) {
}
function tick(automaton) {