1. Shlomi Fish
  2. black-hole-solitaire

Commits

shl...@b384bcd7-cfd4-0310-aca0-d78b80f7b91b  committed 57c0529

Add some client programs.

  • Participants
  • Parent commits d6064d1
  • Branches default

Comments (0)

Files changed (4)

File black-hole-solitaire/range-solving/down-range-remote.pl

View file
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use LWP::UserAgent;
+
+my $ua = LWP::UserAgent->new;
+$ua->timeout(10_000);
+$ua->env_proxy;
+
+my $url = 'http://10.0.0.5:3000/id';
+
+my $remote_box = 'lap';
+my $remote_dir = "\$HOME/progs/games/black-hole-solitaire/trunk/black-hole-solitaire/range-check";
+
+sub fetch_id
+{
+    my $response = $ua->get($url);
+    
+    if ($response->is_success())
+    {
+        my $ret = $response->decoded_content();
+        chomp($ret);
+        return $ret;
+    }
+    else
+    {
+        die $response->status_line();
+    }
+}
+
+while ((my $id = fetch_id()) > 0)
+{
+    print "$id\n";
+    my $fn = "$id.rs";
+
+    my $cond = qx{ssh $remote_box 'cd $remote_dir ; if test -e $fn && ! test -z $fn ; then echo 1 ; else echo 0 ; fi'};
+    chomp($cond);
+
+    if ($cond)
+    {
+        die "$id.rs already exists.";
+    }
+    system(qq{make_pysol_freecell_board.py -F -t "$id" black_hole | }
+        .  qq{black-hole-solve --max-iters 4000000 - | }
+        .  qq{ssh $remote_box 'cat > $remote_dir/$fn'}
+    );
+}

File black-hole-solitaire/range-solving/down-range.pl

View file
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use LWP::UserAgent;
+
+
+my $ua = LWP::UserAgent->new;
+$ua->timeout(10_000);
+$ua->env_proxy;
+
+my $url = 'http://10.0.0.5:3000/id';
+
+sub fetch_id
+{
+    my $response = $ua->get($url);
+    
+    if ($response->is_success())
+    {
+        my $ret = $response->decoded_content();
+        chomp($ret);
+        return $ret;
+    }
+    else
+    {
+        die $response->status_line();
+    }
+}
+
+while ((my $id = fetch_id()) > 0)
+{
+    print "$id\n";
+    my $fn = "$id.rs";
+
+    if (-e $fn && (! -z $fn))
+    {
+        die "$id.rs already exists.";
+    }
+    system(qq{make_pysol_freecell_board.py -F -t "$id" black_hole | }
+        .  qq{black-hole-solve --max-iters 4000000 - > "$fn"}
+    );
+}

File black-hole-solitaire/range-solving/down_range.bash

View file
+#!/bin/bash
+export PATH="$HOME/progs/games/black-hole-solitaire/trunk/black-hole-solitaire/c-solver/build/:$PATH"
+perl down-range.pl 2>&1 | tee -a "$$.black-hole.LOG"

File black-hole-solitaire/range-solving/down_range_remote.bash

View file
+#!/bin/bash
+export PATH="$HOME/progs/games/black-hole-solitaire/trunk/black-hole-solitaire/c-solver/build/:$PATH"
+perl down-range-remote.pl 2>&1 | tee -a "$$.black-hole.LOG"