Commits

Shlomi Fish committed 93ed558

Add the scripts.

This is a range solving based on GNU parallel.

  • Participants
  • Parent commits dac9107

Comments (0)

Files changed (5)

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

+PATH="$HOME/apps/all-in-a-row-solver/bin:$PATH"

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

+#!/bin/bash
+
+source 'prepare.bash'
+
+# Configuration
+start_idx="1"
+end_idx="1,000,000"
+num_cpus="4"
+
+seq "${start_idx//,/}" "${end_idx//,/}" | parallel -j"$num_cpus" perl summarize.pl {}

File black-hole-solitaire/all-in-a-row-gnu-parallel-range-solving/summaries/PLACEHOLDER

Empty file added.

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

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use autodie;
+
+use List::Util qw(first);
+
+my $board_idx = shift(@ARGV);
+
+my $text= `make_pysol_freecell_board.py -F -t $board_idx all_in_a_row | all-in-a-row-solve`;
+
+my ($verdict, $checked, $gen) = ($text =~ m{(Solved|Unsolved).*?^Total number of states checked is (\d+)\..*?^This scan generated (\d+) states\.}ms);
+
+my $v = substr($verdict, 0, 1);
+
+# We are using a temporary place and moving so it will be atomic.
+my $basename = "$board_idx.summary";
+my $temp_fn = "temp-summaries/$basename";
+open my $out_fh, '>', $temp_fn;
+print {$out_fh} "$board_idx\t$v\t$checked\t$gen\n";
+close ($out_fh);
+
+rename ($temp_fn, "summaries/$basename");

File black-hole-solitaire/all-in-a-row-gnu-parallel-range-solving/temp-summaries/PLACEHOLDER

Empty file added.