This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
solution-wrapper
executable file
·53 lines (41 loc) · 1.26 KB
/
solution-wrapper
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/perl
use strict;
use warnings;
use IO::All;
use Path::Tiny qw/ path /;
use Getopt::Long qw(GetOptions);
my ($board_fn, $help);
GetOptions(
'h|help' => \$help,
'board=s' => \$board_fn,
) or die "Wrong arguments - $! - type --help for more info.";
if ($help)
{
print <<'EOF';
This program verifies the Klondike solutions of KlondikeSolver (
https://github.com/shlomif/KlondikeSolver ) and displays them in a more
user-friendly manner.
It requires:
1. An initial board as given by «make_pysol_freecell_board.py -t 24 klondike»
(note the "-t").
2. A solution as given by:
make_pysol_freecell_board.py -t 24 klondike | perl from-fc-solve-board-gen > deck.txt
./KlondikeSolver deck.txt | tee solution.txt
After that run it with --board and --solution and capture its output to
standard output.
EOF
exit(0);
}
if (!defined($board_fn))
{
die "--board or --help not specified.";
}
my $board_str = io->file($board_fn)->all();
my $temp = Path::Tiny->tempdir;
my $board = $temp->child("board.txt");
my $b2 = $temp->child("board2.txt");
my $sol = $temp->child("sol2.txt");
$board->spew_utf8($board_str);
system("< $board from-fc-solve-board-gen > $b2");
system("KlondikeSolver /MOVES $b2 > $sol");
system("display-solution --board $board --solution $sol");