X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=newstable.pl;h=233d317e1f660fcc3b97a432dd4204ec8594fb89;hb=3b542afc856d736dfd2ff0eed081f647de07af4c;hp=402de4f33aaf4e9077476e04c1e0aa5a75a30631;hpb=23c26e0422eda4cb868569e6c3cc4f41fe6e2864;p=clump.git diff --git a/newstable.pl b/newstable.pl index 402de4f..233d317 100644 --- a/newstable.pl +++ b/newstable.pl @@ -4,18 +4,20 @@ use warnings; my @diffs = ( [-1, 0], - [-1, 1], +# [-1, 1], [0 , 1], - [1 , 1], +# [1 , 1], [1 , 0], - [1 , -1], +# [1 , -1], [0 , -1], - [-1, -1] +# [-1, -1] ); my @cpus; -my $side = 4; # there are $side * $side CPUs +my @newstable; + +my $side = 8; # there are $side * $side CPUs for my $line (0 .. ($side - 1)) { $cpus[$line] = [ ($line * $side) .. (($line + 1) * $side - 1) ] @@ -24,9 +26,18 @@ for my $line (0 .. ($side - 1)) { for my $cpu (0 .. ($side * $side - 1)) { my $x = $cpu / $side; my $y = $cpu % $side; - for my $direction (0 .. 7) { + for my $direction (0 .. $#diffs) { my $nx = ($x + $diffs[$direction][0] + $side) % $side; my $ny = ($y + $diffs[$direction][1] + $side) % $side; - say "newstable[$cpu][$direction] = ", $cpus[$nx][$ny], ';'; + $newstable[$cpu][$direction] = $cpus[$nx][$ny]; + } +} + +for my $direction (0 .. $#diffs) { + print "$direction: flag_or_news = {"; + printf 'latest_news[%2d]', $newstable[0][$direction]; + for my $cpu (1 .. ($side * $side - 1)) { + printf ', latest_news[%2d]', $newstable[$cpu][$direction]; } + say '};' }