class Grid {
has Int $.diameter is rw;
has Bool @.state is rw;
submethod BUILD (:$.diameter) {
@.state = 1,;
@.state.push( 0 xx ($.diameter-1) );
}
}Once again, we've taken some shortcuts. The grid code assumes a single dimension, with a second, emergent dimension (often called "time") that happens when you apply the rule.pugs> my Grid $grid .= new( :diameter(10));
pugs> say $grid.state;
1000000000
Labels: cellular automata, deusexautomatis, etech
Subscribe to
Posts [Atom]