Abelian sandpile model: Difference between revisions
Content added Content deleted
m (Phix/pGUI) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: Backport some tweaks and minor bug squashing) |
||
Line 1,664: | Line 1,664: | ||
loop (my int $idx = $rs; $idx < $re; $idx = $idx + 1) { |
loop (my int $idx = $rs; $idx < $re; $idx = $idx + 1) { |
||
if @buffer[$idx] >= 4 { |
if @buffer[$idx] >= 4 { |
||
my $grains = @buffer[$idx] div 4; |
|||
@buffer[ $idx - $w ] += $grains if $row > 0; |
|||
@buffer[ $idx - 1 ] += $grains if $idx - 1 >= $rs; |
|||
@buffer[ $idx + $w ] += $grains if $row < $h - 1; |
|||
@buffer[ $idx ] |
@buffer[ $idx + 1 ] += $grains if $idx + 1 < $re; |
||
@buffer[ $idx ] %= 4; |
|||
$done = False; |
$done = False; |
||
} |
} |
||
Line 1,674: | Line 1,675: | ||
} |
} |
||
unless $hide-progress { |
unless $hide-progress { |
||
print "\e[1;1H", @buffer.map( { @color[$_ min 4] } |
print "\e[1;1H", @buffer.map( { @color[$_ min 4] }).join; |
||
} |
} |
||
} until $done; |
} until $done; |
||
print "\e[1;1H", @buffer.map( { @color[$_ min 4] } |
print "\e[1;1H", @buffer.map( { @color[$_ min 4] }).join; |
||
cleanup;</lang> |
cleanup;</lang> |