Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ddugovic
Last active November 7, 2016 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddugovic/4bd22206268a77726e8be55b784ac09d to your computer and use it in GitHub Desktop.
Save ddugovic/4bd22206268a77726e8be55b784ac09d to your computer and use it in GitHub Desktop.
Disclaimer: this generates some redundant files and puts files in the . directory unless specified otherwise
#!/usr/bin/perl
$ENV{'STBWDIR'} = '.';
$ENV{'STBZDIR'} = '.';
$ENV{'STBSTATSDIR'} = '.';
$ENV{'LTBWDIR'} = '.';
$ENV{'LTBZDIR'} = '.';
$ENV{'LTBSTATSDIR'} = '.';
$ENV{'GTBWDIR'} = '.';
$ENV{'GTBZDIR'} = '.';
$ENV{'GTBSTATSDIR'} = '.';
$ENV{'ATBWDIR'} = '.';
$ENV{'ATBZDIR'} = '.';
$ENV{'ATBSTATSDIR'} = '.';
$ENV{'RTBWDIR'} = '.';
$ENV{'RTBZDIR'} = '.';
$ENV{'RTBSTATSDIR'} = '.';
use Getopt::Long;
$threads = 4;
$generate = '';
$verify = '';
$wdl = '';
$pieces = 'KQRBNP';
$min = 2;
$max = 4;
$disk = '';
GetOptions('threads=i' => \$threads,
'generate' => \$generate,
'verify' => \$verify,
'wdl' => \$wdl,
'pieces=s' => \$pieces,
'min=i' => \$min,
'max=i' => \$max,
'disk' => \$disk);
sub Execute {
my $cmd = shift;
print "$cmd\n";
die if system($cmd);
}
sub Process {
my($tb) = @_;
my $len = length($tb) - 1;
if ($len < $min || $len > $max) { return; }
$wopt = "";
if ($wdl) {
$wopt = "-w ";
}
$dopt = "";
if ($disk && $len == 6) {
$dopt = "-d ";
}
if ($generate && $tb =~ /^K[^K]+vK[^K]*$/ && !-e $tb.".rtbz") {
print "\nGenerating $tb\n";
if ($tb !~ /P/) {
Execute("src/rtbgen $wopt$dopt-t $threads --stats $tb");
} else {
Execute("src/rtbgenp $wopt$dopt-t $threads --stats $tb");
}
}
if ($generate && $tb =~ /^K[^K]+vK[^K]*$/ && !-e $tb.".atbz") {
print "\nGenerating $tb\n";
if ($tb !~ /P/) {
Execute("src/atbgen $wopt$dopt-t $threads --stats $tb");
} else {
Execute("src/atbgenp $wopt$dopt-t $threads --stats $tb");
}
}
if ($generate && !-e $tb.".gtbz") {
print "\nGenerating $tb\n";
if ($tb !~ /P/) {
Execute("src/gtbgen $wopt$dopt-t $threads --stats $tb");
} else {
Execute("src/gtbgenp $wopt$dopt-t $threads --stats $tb");
}
}
if ($generate && !-e $tb.".stbz") {
print "\nGenerating $tb\n";
if ($tb !~ /P/) {
Execute("src/stbgen $wopt$dopt-t $threads --stats $tb");
} else {
Execute("src/stbgenp $wopt$dopt-t $threads --stats $tb");
}
}
if ($verify) {
printf "\nVerifying $tb\n";
if ($tb !~ /P/) {
if (-e $tb.".rtbz") { Execute("src/rtbver $wopt-t $threads --log $tb"); }
if (-e $tb.".atbz") { Execute("src/atbver $wopt-t $threads --log $tb"); }
if (-e $tb.".gtbz") { Execute("src/gtbver $wopt-t $threads --log $tb"); }
if (-e $tb.".stbz") { Execute("src/stbver $wopt-t $threads --log $tb"); }
} else {
if (-e $tb.".rtbz") { Execute("src/rtbverp $wopt-t $threads --log $tb"); }
if (-e $tb.".atbz") { Execute("src/atbverp $wopt-t $threads --log $tb"); }
if (-e $tb.".gtbz") { Execute("src/gtbverp $wopt-t $threads --log $tb"); }
if (-e $tb.".stbz") { Execute("src/stbverp $wopt-t $threads --log $tb"); }
}
}
}
@Pieces = unpack '(A)*', $pieces;
$N = scalar (@Pieces);
for ($i = 0; $i < $N; ++$i) {
$a = @Pieces[$i];
for ($j = $i; $j < $N; ++$j) {
$b = @Pieces[$j];
$tb = $a."v".$b;
Process($tb);
}
}
for ($i = 0; $i < $N; ++$i) {
$a = @Pieces[$i];
for ($j = $i; $j < $N; ++$j) {
$b = @Pieces[$j];
for ($k = 0; $k < $N; ++$k) {
$c = @Pieces[$k];
$tb = $a.$b."v".$c;
Process($tb);
}
}
}
for ($i = 0; $i < $N; ++$i) {
$a = @Pieces[$i];
for ($j = $i; $j < $N; ++$j) {
$b = @Pieces[$j];
for ($k = $j; $k < $N; ++$k) {
$c = @Pieces[$k];
for ($l = 0; $l < $N; ++$l) {
$d = @Pieces[$l];
$tb = $a.$b.$c."v".$d;
Process($tb);
}
}
}
}
for ($i = 0; $i < $N; ++$i) {
$a = @Pieces[$i];
for ($j = $i; $j < $N; ++$j) {
$b = @Pieces[$j];
for ($k = 0; $k < $N; ++$k) {
$c = @Pieces[$k];
for ($l = $k; $l < $N; ++$l) {
$d = @Pieces[$l];
$tb = $a.$b."v".$c.$d;
Process($tb);
}
}
}
}
for ($i = 0; $i < $N; ++$i) {
$a = @Pieces[$i];
for ($j = $i; $j < $N; ++$j) {
$b = @Pieces[$j];
for ($k = $j; $k < $N; ++$k) {
$c = @Pieces[$k];
for ($l = $k; $l < $N; ++$l) {
$d = @Pieces[$l];
for ($m = 0; $m < $N; ++$m) {
$e = @Pieces[$m];
$tb = $a.$b.$c.$d."v".$e;
Process($tb);
}
}
}
}
}
for ($i = 0; $i < $N; ++$i) {
$a = @Pieces[$i];
for ($j = $i; $j < $N; ++$j) {
$b = @Pieces[$j];
for ($k = $j; $k < $N; ++$k) {
$c = @Pieces[$k];
for ($l = 0; $l < $N; ++$l) {
$d = @Pieces[$l];
for ($m = $l; $m < $N; ++$m) {
$e = @Pieces[$m];
$tb = $a.$b.$c."v".$d.$e;
Process($tb);
}
}
}
}
}
for ($i = 0; $i < $N; ++$i) {
$a = @Pieces[$i];
for ($j = $i; $j < $N; ++$j) {
$b = @Pieces[$j];
for ($k = $j; $k < $N; ++$k) {
$c = @Pieces[$k];
for ($l = $k; $l < $N; ++$l) {
$d = @Pieces[$l];
for ($m = $l; $m < $N; ++$m) {
$e = @Pieces[$m];
for ($n = 0; $n < $N; ++$n) {
$f = @Pieces[$n];
$tb = $a.$b.$c.$d.$e."v".$f;
Process($tb);
}
}
}
}
}
}
for ($i = 0; $i < $N; ++$i) {
$a = @Pieces[$i];
for ($j = $i; $j < $N; ++$j) {
$b = @Pieces[$j];
for ($k = $j; $k < $N; ++$k) {
$c = @Pieces[$k];
for ($l = $k; $l < $N; ++$l) {
$d = @Pieces[$l];
for ($m = 0; $m < $N; ++$m) {
$e = @Pieces[$m];
for ($n = $m; $n < $N; ++$n) {
$f = @Pieces[$n];
$tb = $a.$b.$c.$d."v".$e.$f;
Process($tb);
}
}
}
}
}
}
for ($i = 0; $i < $N; ++$i) {
$a = @Pieces[$i];
for ($j = $i; $j < $N; ++$j) {
$b = @Pieces[$j];
for ($k = $j; $k < $N; ++$k) {
$c = @Pieces[$k];
for ($l = 0; $l < $N; ++$l) {
$d = @Pieces[$l];
for ($m = $l; $m < $N; ++$m) {
$e = @Pieces[$m];
for ($n = $m; $n < $N; ++$n) {
$f = @Pieces[$n];
$tb = $a.$b.$c."v".$d.$e.$f;
Process($tb);
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment