@@ -15,14 +15,14 @@ function CA(r) {
1515
1616 // Make a random ruleset
1717 this . randomize = function ( ) {
18- for ( var i = 0 ; i < 8 ; i ++ ) {
18+ for ( let i = 0 ; i < 8 ; i ++ ) {
1919 this . ruleset [ i ] = Math . floor ( random ( 2 ) ) ;
2020 }
2121 } ;
2222
2323 // Reset to generation 0
2424 this . restart = function ( ) {
25- for ( var i = 0 ; i < this . cells . length ; i ++ ) {
25+ for ( let i = 0 ; i < this . cells . length ; i ++ ) {
2626 this . cells [ i ] = 0 ;
2727 }
2828 // We arbitrarily start with just the middle cell having a state of "1"
@@ -34,13 +34,13 @@ function CA(r) {
3434 // The process of creating the new generation
3535 this . generate = function ( ) {
3636 // First we create an empty array for the new values
37- var nextgen = new Array ( this . cells . length ) ;
37+ let nextgen = new Array ( this . cells . length ) ;
3838 // For every spot, determine new state by examing current state, and neighbor states
3939 // Ignore edges that only have one neighor
40- for ( var i = 1 ; i < this . cells . length - 1 ; i ++ ) {
41- var left = this . cells [ i - 1 ] ; // Left neighbor state
42- var me = this . cells [ i ] ; // Current state
43- var right = this . cells [ i + 1 ] ; // Right neighbor state
40+ for ( let i = 1 ; i < this . cells . length - 1 ; i ++ ) {
41+ let left = this . cells [ i - 1 ] ; // Left neighbor state
42+ let me = this . cells [ i ] ; // Current state
43+ let right = this . cells [ i + 1 ] ; // Right neighbor state
4444 nextgen [ i ] = this . rules ( left , me , right ) ; // Compute next generation state based on ruleset
4545 }
4646 // The current generation is the new generation
@@ -50,7 +50,7 @@ function CA(r) {
5050
5151 // This is the easy part, just draw the cells, fill 255 for '1', fill 0 for '0'
5252 this . display = function ( ) {
53- for ( var i = 0 ; i < this . cells . length ; i ++ ) {
53+ for ( let i = 0 ; i < this . cells . length ; i ++ ) {
5454 if ( this . cells [ i ] == 1 ) fill ( 200 ) ;
5555 else fill ( 51 ) ;
5656 noStroke ( ) ;
0 commit comments