Commits

Shlomi Fish  committed f96c1c5

Generalised the range solving.

Allow to use prune or non-prune and a different game each time.

  • Participants
  • Parent commits a68ea8b

Comments (0)

Files changed (2)

File black-hole-solitaire/all-in-a-row-gnu-parallel-range-solving/range-solving.bash

 
 # Configuration
 start_idx="1"
-end_idx="1,000,000"
+# end_idx="1,000,000"
+end_idx="10,000"
 num_cpus="4"
+game="black_hole"
+prune="true"
 
 if test -f SUMMARY.txt ; then
     start_idx="$(tail -1 SUMMARY.txt | perl -lpe 's/\D.*//')"
     let start_idx++
 fi
 
+args=''
+args+=" --game=$game"
+if $prune ; then
+    args+=" --prune"
+fi
+
 seq "${start_idx//,/}" "${end_idx//,/}" | \
-    parallel --ungroup --sshlogin 4/sh --sshlogin 2/lap \
-    perl "$(pwd)"/summarize.pl {}
+    # parallel --ungroup --sshlogin 4/sh --sshlogin 2/lap \
+    parallel --ungroup -j4 \
+    perl "$(pwd)"/summarize.pl $args {}

File black-hole-solitaire/all-in-a-row-gnu-parallel-range-solving/summarize.pl

 use List::Util qw(first);
 use File::Copy qw(copy);
 use Env::Path;
+use Getopt::Long qw(GetOptions);
 
 my $p = Env::Path->PATH;
 
 my $bhs_dir = "$ENV{HOME}/apps/black-hole-solver";
 $p->Prepend("$bhs_dir/bin");
 
+my $game;
+my $is_prune = 0;
+if (! GetOptions(
+    'prune!' => \$is_prune,
+    'game|g=s' => \$game,
+))
+{
+    die "Invalid options!";
+}
+
+if (!defined($game))
+{
+    die "--game|-g was not specified!";
+}
+
+if (not (($game eq 'black_hole') || ($game eq 'all_in_a_row')))
+{
+    die "Invalid game type";
+}
+
 my $board_idx = shift(@ARGV);
 
 my $basename = "$board_idx.summary";
     exit(0);
 }
 
-my $game = 'all_in_a_row';
-my @args = (qw(--rank-reach-prune));
-my $text= `make_pysol_freecell_board.py -F -t $board_idx $game | black-hole-solve --game $game @args -`;
+my @args;
+
+if ($is_prune)
+{
+    push @args, (qw(--rank-reach-prune));
+}
+
+my $text = `make_pysol_freecell_board.py -F -t $board_idx $game | black-hole-solve --game $game @args -`;
 
 my ($verdict, $checked, $gen) = ($text =~ m{(Solved|Unsolved).*?^Total number of states checked is (\d+)\..*?^This scan generated (\d+) states\.}ms);