simplify paths produced by graphplay
[perl/schtarr.git] / graphplay
index d6baebfe517f1102a120bc8d6061948739f7ffd7..9956168612fe29ce5ba3903b1eda95d3a109189e 100755 (executable)
--- a/graphplay
+++ b/graphplay
@@ -54,6 +54,22 @@ for my $input (@ARGV) {
                }
        }
 
+       for (0 .. 2) {
+               my $line = $lines[$_][$player];
+               my $start;
+               my $lasty;
+               for (my $i = 1; $i <= $#$line; $i++) {
+                       defined $line->[$i] or next;
+                       if ($line->[$i][1] == $line->[$i - 1][1]) {
+                               $start = $i unless defined $start;
+                       } elsif (defined $start) {
+                               delete @$line[$start .. $i-2];
+                               undef $start;
+                       }
+               }
+               delete @$line[$start .. $#$line-2] if defined $start; # or -1
+       }
+
        $player++;
 }