]> iEval git - clump.git/blobdiff - newstable.pl
Add diagrams and pictures
[clump.git] / newstable.pl
index 402de4f33aaf4e9077476e04c1e0aa5a75a30631..67957b8d8da967c0e78d3dd9446823630b007219 100644 (file)
@@ -4,17 +4,19 @@ use warnings;
 
 my @diffs = (
        [-1,  0],
-       [-1,  1],
        [0 ,  1],
-       [1 ,  1],
        [1 ,  0],
-       [1 , -1],
        [0 , -1],
-       [-1, -1]
+       [-1, -1],
+       [-1,  1],
+       [1 ,  1],
+       [1 , -1],
 );
 
 my @cpus;
 
+my @newstable;
+
 my $side = 4; # there are $side * $side CPUs
 
 for my $line (0 .. ($side - 1)) {
@@ -24,9 +26,19 @@ 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: news_out = {";
+       printf 'news_in[%2d]', $newstable[$side * $side - 1][$direction];
+       my @lst = 0 .. ($side * $side - 2);
+       for my $cpu (reverse @lst) {
+               printf ', news_in[%2d]', $newstable[$cpu][$direction];
        }
+       say '};'
 }
This page took 0.025572 seconds and 4 git commands to generate.