Commits

Shlomi Fish committed 894c057

Moved some scripts under scripts/

git-svn-id: file:///home/shlomif/Backup/svn-dumps/google-code/svnsync-repos/fc-solve/trunk@1397 e7e8a897-7ba4-4ee7-b36f-f4c66519b19a

Comments (0)

Files changed (6)

fc-solve/source/gen_makefile.pl

-#!/usr/bin/perl
-
-use strict;
-
-sub min
-{
-    my $ret = shift;
-    foreach (@_)
-    {
-        if ($_ < $ret)
-        {
-            $ret = $_;
-        }
-    }
-
-    return $ret;
-}
-
-my @objects=(
-    qw(alloc app_str caas card cl_chop cmd_line fcs_dm fcs_hash fcs_isa),
-    qw(freecell intrface lib lookup2 move pqueue preset rand),
-    qw(scans simpsim state)
-    );
-
-my @targets = (
-    {
-        'exe' => "fc-solve",
-        'objs' => [ qw(main) ],
-    },
-    {
-        'exe' => "freecell-solver-range-parallel-solve",
-        'objs' => [ qw(test_multi_parallel) ],
-    },
-);
-
-my @headers_proto=
-    (
-        qw(alloc app_str caas card cl_chop), { 'name' => "config", 'gen' => 1},
-            qw(fcs_cl fcs fcs_dm fcs_enums),
-        qw(fcs_hash fcs_isa fcs_move fcs_user inline jhjtypes lookup2),
-        qw(move ms_ca), {'name' => "prefix", 'gen' => 1},
-            qw(pqueue preset rand state test_arr tests)
-    );
-
-my @headers = (map { ref($_) eq "HASH" ? $_->{'name'} : $_ } @headers_proto);
-
-my @defines=(qw(WIN32));
-
-my @debug_defines = (qw(DEBUG));
-
-print "all: fc-solve.exe freecell-solver-range-parallel-solve.exe\n\n";
-
-print "OFLAGS=" . "/Og2 " . join(" ", (map { "/D".$_ } @defines)) . "\n";
-print "DFLAGS=\$(OFLAGS) " . join(" ", (map { "/D".$_ } @debug_defines)) . "\n";
-
-print "INCLUDES=" . join(" ", (map { $_.".h" } @headers)). "\n";
-print "CC=cl\n";
-print "LIB32=link.exe\n";
-
-
-print "\n\n";
-
-print "OBJECTS = " . join(" ", (map { $_.".obj" } @objects)) . "\n";
-
-print "\n\n";
-
-foreach my $o (@objects, (map { @{$_->{'objs'}} } @targets))
-{
-    print "$o.obj: $o.c \$(INCLUDES)\n";
-    print "\t\$(CC) /c /Fo$o.obj \$(OFLAGS) $o.c\n";
-    print "\n";
-}
-
-print "\n\n###\n### Final Targets\n###\n\n\n";
-
-foreach my $t (@targets)
-{
-    my $exe = $t->{'exe'};
-    my @objs = @{$t->{'objs'}};
-
-    #my $obj_line = "\$(OBJECTS) " . join(" ", (map { "$_.obj" } @objs));
-    my $obj_line = "freecell-solver-static.lib " . join(" ", (map { "$_.obj" } @objs));
-
-    print "$exe.exe: $obj_line\n";
-    print "\t\$(CC) /Fe$exe.exe /F0x2000000 $obj_line\n";
-    print "\n";
-}
-
-print "freecell-solver-static.lib: \$(OBJECTS)\n";
-print "\t\$(LIB32) -lib \$(OBJECTS) /out:freecell-solver-static.lib\n";
-print "\n";
-
-print "freecell-solver.dll: \$(OBJECTS) freecell-solver.def\n";
-print "\t\$(LIB32) kernel32.lib user32.lib gdi32.lib /dll /out:freecell-solver.dll /implib:freeecell-solver.lib /DEF:freecell-solver.def \$(OBJECTS) \n";
-print "\n";
-
-#print "fc-solve.exe: \$(OBJECTS)\n";
-#print "\t\$(CC) /Fefc-solve.exe /F0x2000000 \$(OBJECTS)\n";
-#print "\n";
-
-print "clean:\n";
-print "\tdel *.obj *.exe *.lib *.dll *.exp\n";
-
-open I, "<Makefile.am";
-open O, ">Makefile.am.new";
-while (<I>)
-{
-    if (/^libfreecell_solver_la_SOURCES *=/)
-    {
-        print O "libfreecell_solver_la_SOURCES = " . join(" ", (map { "$_.c" } @objects)) . "\n";
-    }
-    elsif (/^#<<<HEADERS\.START/)
-    {
-        while(! /^#>>>HEADERS\.END/)
-        {
-            $_ = <I>;
-        }
-        print O "#<<<HEADERS.START\n";
-        my @headers_no_gen = map { (ref($_) eq "HASH") ? $_->{'name'} : $_ } (grep { (ref($_) eq "HASH") ? (! $_->{'gen'}) : 1 } @headers_proto);
-        for my $i (0 .. ((int(scalar(@headers_no_gen)/5)+((scalar(@headers_no_gen)%5) > 0))-1))
-        {
-            print O "EXTRA_DIST += " . join(" ", map { "$_.h" } @headers_no_gen[($i*5) .. min($i*5+4, $#headers_no_gen)]) . "\n";
-        }
-        print O "#>>>HEADERS.END\n";
-    }
-    else
-    {
-        print O $_;
-    }
-}
-close(O);
-close(I);
-rename("Makefile.am.new", "Makefile.am");
-
-open I, "<Makefile.gnu";
-open O, ">Makefile.gnu.new";
-while(<I>)
-{
-    if (/^#<<<OBJECTS\.START/)
-    {
-        while(! /^#>>>OBJECTS\.END/)
-        {
-            $_ = <I>;
-        }
-        print O "#<<<OBJECTS.START\n";
-        print O "OBJECTS = " . (" " x 20) . "\\\n";
-        print O join("", (map { sprintf((" " x 10) . "%-20s\\\n", ($_.".o")) } @objects));
-        print O "\n";
-        print O "#>>>OBJECTS.END\n";
-    }
-    else
-    {
-        print O $_;
-    }
-}
-close(O);
-close(I);
-rename("Makefile.gnu.new", "Makefile.gnu");
-
-open I, "<Makefile.lite";
-open O, ">Makefile.lite.new";
-while(<I>)
-{
-    if (/^INCLUDES *=/)
-    {
-        print O "INCLUDES = " . join(" ", (map { "$_.h" } @headers)) . "\n";
-    }
-    elsif (/^#<<<OBJECTS\.START/)
-    {
-        while(! /^#>>>OBJECTS\.END/)
-        {
-            $_ = <I>;
-        }
-        my @ext_objects = (@objects, "main");
-        print O "#<<<OBJECTS.START\n";
-        print O join("\n\n", (map { "$_.o: $_.c \$(INCLUDES)\n\t\$(CC) -c \$(OFLAGS) -o \$@ \$<" } @ext_objects));
-        print O "\n\nOBJECTS = " . join(" ", (map { "$_.o" } @ext_objects)) . "\n";
-        print O "#>>>OBJECTS.END\n";
-    }
-    else
-    {
-        print O $_;
-    }
-}
-close(O);
-close(I);
-rename("Makefile.lite.new", "Makefile.lite");
-

fc-solve/source/gen_presets.pl

-#!/usr/bin/perl -w
-
-use strict;
-
-my %presets =
-(
-    'bakers_game' => [ qw(i freecell sbb suit) ],
-    'bakers_dozen' => [ qw(s 13 f 0 d 1 sbb rank sm limited esf none to 0123456789 at 0123456789) ],
-    'beleaguered_castle' => [ qw(i freecell sbb rank f 0) ],
-    'cruel' => [ qw(i bakers_dozen s 12 sbb suit) ],
-    'der_katzenschwanz' => [ qw(i die_schlange sm unlimited) ],
-    'die_schlange' => [ qw(i freecell f 8 s 9 d 2 esf none) ],
-    'eight_off' => [ qw(i kings_only_bakers_game f 8) ],
-    'fan' => [ qw(i freecell s 18 sbb suit sm limited esf kings_only f 0) ],
-    'forecell' => [ qw(i freecell esf kings_only) ],
-    'freecell' => [ qw(s 8 f 4 d 1 sbb ac sm limited esf any_card to [01][23456789] at 0123456789) ],
-    'good_measure' => [ qw(i bakers_dozen s 10) ],
-    'kings_only_bakers_game' => [ qw(i bakers_game esf kings_only) ],
-    'relaxed_freecell' => [ qw(i freecell sm unlimited) ],
-    'relaxed_seahaven_towers' => [ qw(i seahaven_towers sm unlimited) ],
-    'seahaven_towers' => [ qw(i bakers_game esf kings_only s 10) ],
-    'simple_simon' => [ qw(i bakers_game s 10 f 0 to abcdefgh at abcdefgh) ],
-    # 'yukon' => [ qw(i freecell s 7 f 0 to ABCDEFG) ],
-);
-
-my @strings;
-
-sub compile_preset
-{
-    my $preset_name = shift;
-
-    my $preset = $presets{$preset_name};
-
-    # For inheritance
-    my $compiled = shift || {};
-
-    my @params = @{$preset};
-
-    my ($cmd, $arg);
-
-    eval {
-
-    while ($cmd = shift(@params))
-    {
-        $arg = shift(@params);
-
-        if ($cmd =~ /^(i|inherits?)$/)
-        {
-            if (!exists($presets{$arg}))
-            {
-                die "Unknown inheritor!\n";
-            }
-            compile_preset($arg, $compiled);
-        }
-        elsif ($cmd =~ /^(s|stacks?)$/)
-        {
-            if ($arg !~ /^(\d+)$/)
-            {
-                die "Argument to stacks is not an integer!\n";
-            }
-            $compiled->{'stacks'} = $arg;
-        }
-        elsif ($cmd =~ /^(f|freecells?)$/)
-        {
-            if ($arg !~ /^(\d+)$/)
-            {
-                die "Argument to freecells is not an integer!\n";
-            }
-            $compiled->{'freecells'} = $arg;
-        }
-        elsif ($cmd =~ /^(d|decks?)$/)
-        {
-            if ($arg !~ /^(1|2)$/)
-            {
-                die "Argument to decks is not 1 or 2!\n";
-            }
-            $compiled->{'decks'} = $arg;
-        }
-        elsif ($cmd =~ /^(sbb|seqs_build_by)$/)
-        {
-            if ($arg !~ /^(ac|suit|rank)$/)
-            {
-                die "Argument to stacks_build_by is improper!\n";
-            }
-            $compiled->{'seqs_build_by'} = $arg;
-        }
-        elsif ($cmd =~ /^(sm|(seq|sequence)_move)$/)
-        {
-            if ($arg !~ /^(limited|unlimited)$/)
-            {
-                die "Argument to sequence move is not limited/unlimited!\n";
-            }
-            $compiled->{'sequence_move'} = (($arg eq "unlimited")?1:0);
-        }
-        elsif ($cmd =~ /^(esf|empty_stacks_fill(ed(_by)?)?)$/)
-        {
-            if ($arg !~ /^(any_card|kings_only|none)$/)
-            {
-                die "Improper parameter to Empty Stacks Filled By!\n";
-            }
-            $compiled->{'empty_stacks_fill'} = $arg;
-        }
-        elsif ($cmd =~ /^(to|tests_order)$/)
-        {
-            if ($arg =~ /[^0-9a-hA-G\[\(\)\]]/)
-            {
-                die "Unrecognized character in Tests order!\n";
-            }
-            $compiled->{'tests_order'} = $arg;
-        }
-        elsif ($cmd =~ /^(at|allowed_tests)$/)
-        {
-            if ($arg =~ /[^0-9a-hA-G]/)
-            {
-                die "Unrecognized character in Allowed Tests!\n";
-            }
-            $compiled->{'allowed_tests'} = $arg;
-        }
-        else
-        {
-            die "Unknown Command $cmd\n";
-        }
-    }
-
-    };
-
-    if ($@)
-    {
-        die "Preset Name: $preset_name\n$@";
-    }
-
-    return $compiled;
-}
-
-sub preset_to_string
-{
-    my $preset_name = shift;
-    my $pc = shift;
-
-    my @lines = ();
-
-    my $arg;
-
-    eval
-    {
-
-    push @lines, ("FCS_PRESET_" . uc($preset_name));
-
-    if (!exists($pc->{'freecells'}))
-    {
-        die "Freecells were not defined!\n";
-    }
-    push @lines, $pc->{'freecells'};
-
-    if (!exists($pc->{'stacks'}))
-    {
-        die "Stacks were not defined!\n";
-    }
-    push @lines,  $pc->{'stacks'};
-
-    if (!exists($pc->{'decks'}))
-    {
-        die "Decks Number was not defined!\n";
-    }
-    push @lines,  $pc->{'decks'};
-
-    if (!exists($pc->{'seqs_build_by'}))
-    {
-        die "Seqs Build by was not defined!\n";
-    }
-    $arg = $pc->{'seqs_build_by'};
-    push @lines, ("FCS_SEQ_BUILT_BY_". (($arg eq "ac") ? "ALTERNATE_COLOR" : ($arg eq "suit") ? "SUIT" : "RANK"));
-
-    if (!exists($pc->{'sequence_move'}))
-    {
-        die "Sequence move was not defined!\n";
-    }
-    push @lines, $pc->{'sequence_move'};
-
-    if (!exists($pc->{'empty_stacks_fill'}))
-    {
-        die "Empty Stacks Fill is undefined!\n";
-    }
-    $arg = $pc->{'empty_stacks_fill'};
-    push @lines, "FCS_ES_FILLED_BY_" . (($arg eq "none") ? "NONE" : ($arg eq "any_card") ? "ANY_CARD" : "KINGS_ONLY");
-
-    if (!exists($pc->{'tests_order'}))
-    {
-        die "Tests order is undefined!\n";
-    }
-    push @lines, "\"" . $pc->{'tests_order'} . "\"";
-
-    if (!exists($pc->{'allowed_tests'}))
-    {
-        die "Allowed Tests' is undefined!\n";
-    }
-    push @lines, "\"" . $pc->{'allowed_tests'} . "\"";
-
-    };
-
-    if ($@)
-    {
-        die "Preset name: $preset_name\n$@\n";
-    }
-
-    my @lines_p = (map { "        $_," } @lines);
-    my @lines_with_spaces = (@lines_p[0 .. 3], "", @lines_p[4 .. 6], "", @lines_p[7 .. $#lines_p]);
-
-    return "    {\n" . join("\n", @lines_with_spaces) . "\n" . "    },\n";
-}
-
-sub preset_to_docbook_string
-{
-    my $preset_name = shift;
-    my $pc = shift;
-    my @lines;
-
-    push @lines, join(" ", (map { ucfirst($_) } split(/_/, $preset_name)));
-
-    push @lines, ($pc->{'stacks'}, $pc->{'freecells'}, $pc->{'decks'});
-
-    my $sbb = $pc->{'seqs_build_by'};
-    push @lines,
-        (($sbb eq "ac") ? "Alternate Colour" :
-            ($sbb eq "suit") ? "Suit" :
-            "Rank");
-
-    my $arg = $pc->{'empty_stacks_fill'};
-    push @lines, (($arg eq "none") ? "None" : ($arg eq "any_card") ? "Any Card" : "Kings Only");
-
-    push @lines, ($pc->{'sequence_move'} ? "Limited" : "Unlimited");
-
-    return join("", map { "    <entry>$_</entry>\n" } @lines);
-}
-
-
-sub preset_to_perl_module
-{
-    my $preset_name = shift;
-    my $pc = shift;
-
-    my %sbb_map =
-    (
-        'ac' => "alt_color",
-        'suit' => "suit",
-        'rank' => "rank",
-    );
-
-    my $sbb = $sbb_map{$pc->{'seqs_build_by'}}
-        or die "Hoola";
-
-    my %esf_map =
-    (
-        'kings_only' => "kings",
-        'none' => "none",
-        'any_card' => "any",
-    );
-    my $esf = $esf_map{$pc->{'empty_stacks_fill'}}
-        or die "BlahBlajjor";
-
-    my $seq_move = $pc->{sequence_move} ? "unlimited" : "limited";
-
-    return <<"EOF";
-    "$preset_name" =>
-        Games::Solitaire::Verify::VariantParams->new(
-            {
-                'num_decks' => $pc->{decks},
-                'num_columns' => $pc->{stacks},
-                'num_freecells' => $pc->{freecells},
-                'sequence_move' => "$seq_move",
-                'seq_build_by' => "$sbb",
-                'empty_stacks_filled_by' => "$esf",
-            }
-        ),
-EOF
-}
-
-sub preset_to_pod
-{
-    my $preset_name = shift;
-    my $pc = shift;
-
-    return "=item * $preset_name\n\n";
-}
-
-my $mode = "c";
-
-my $mode_arg = shift(@ARGV);
-
-if ($mode_arg eq "--docbook")
-{
-    $mode = "docbook";
-}
-elsif ($mode_arg eq "--perlmod")
-{
-    $mode = "perl-mod";
-}
-elsif ($mode_arg eq "--pod")
-{
-    $mode = "pod";
-}
-
-my %mode_callbacks =
-(
-    "c" => \&preset_to_string,
-    "docbook" => \&preset_to_docbook_string,
-    "perl-mod" => \&preset_to_perl_module,
-    "pod" => \&preset_to_pod,
-);
-
-foreach my $preset_name (sort {$a cmp $b } keys(%presets))
-{
-    if (($mode ne "c") && ($preset_name eq "simple_simon"))
-    {
-        next;
-    }
-
-    my $preset_compiled = compile_preset($preset_name);
-    push @strings, $mode_callbacks{$mode}->($preset_name, $preset_compiled);
-}
-
-if ($mode eq "docbook")
-{
-    print join("", map { "<row>\n$_</row>\n" } @strings);
-}
-elsif ($mode eq "c")
-{
-    print "static const fcs_preset_t fcs_presets[" . scalar(@strings) . "] = \n";
-    print "{\n";
-    print join("", @strings);
-    print "};\n";
-}
-elsif ($mode eq "perl-mod")
-{
-    print "my %variants_map =\n";
-    print "(\n";
-    print join("", @strings);
-    print ");\n";
-}
-elsif ($mode eq "pod")
-{
-    print "=head1 PARAMETERS\n\n";
-
-    print "=head2 Variants IDs\n\n";
-
-    print "This is a list of the available variant IDS.\n\n";
-
-    print "=over 4\n\n";
-
-    print join("",@strings);
-
-    print "=back\n\n";
-}

fc-solve/source/prepare-for-cmd-line-radix-tree.pl

-#!/usr/bin/perl
-
-use strict;
-use warnings;
-use List::Util qw(first);
-
-my $text_out;
-my $find_prefix;
-my $process_opts = "";
-my $enum = "enum FCS_COMMAND_LINE_OPTIONS\n{\n";
-my $text_in = "";
-my $ws_prefix;
-my $in = 0;
-
-my $module_filename = "cmd_line.c";
-open my $module, "<", $module_filename;
-while (my $line = <$module>)
-{
-    if (($line =~ m{\A(\s*)/\* OPT-PARSE-START \*/})
-           ..
-        ($line =~ m{/\* OPT-PARSE-END \*/})
-    )
-    {
-        $in = 1;
-        if (!defined($ws_prefix))
-        {
-            $ws_prefix = $1;
-        }
-
-        my $inner_strcmp_regex = qr{!strcmp *\( *argv\[arg\] *, *"-[a-zA-Z\-]+" *\) *};
-        my $strcmp_regex = qr{\($inner_strcmp_regex\)|$inner_strcmp_regex};
-
-        my $complete_strcmp = ($line =~ m{\A\Q$ws_prefix\Eelse if \((?:$strcmp_regex *\|\| *)*$strcmp_regex\) *\n?\z}ms);
-
-        my $is_start_line = ($line =~ m{\A\Q$ws_prefix\Eelse if \( *\n?\z}ms);
-        if ($complete_strcmp || $is_start_line)
-        {
-            if ($is_start_line)
-            {
-                NEXT_LINE_LOOP:
-                while (my $next_line = <$module>)
-                {
-                    $line .= $next_line;
-                    if ($next_line =~ m{\A\Q$ws_prefix\E *\) *\n?\z})
-                    {
-                        last NEXT_LINE_LOOP;
-                    }
-                }
-            }
-            my @strings = ($line =~ m{"([^"]+)"}g);
-            my $first = first { m{\A--} } @strings;
-            if (!defined($first))
-            {
-                $first = $strings[0];
-            }
-
-            $first =~ s{\A-*}{};
-            $first =~ tr{-}{_};
-            my $opt = "FCS_OPT_" . uc($first);
-
-            my $indent = "        ";
-            $find_prefix .= join("",
-                map { $indent. $_ . "\n" }
-                (
-                    ("else if (" . join("||", map { qq{(!strcmp(argv[arg], "$_"))} } @strings) . ")"),
-                    "{",
-                    "    opt = $opt;",
-                    "}"
-                )
-            );
-
-            $process_opts .= "${ws_prefix}case ${opt}: /* STRINGS=" . join("|", @strings) . ";" . " */\n";
-
-            do
-            {
-                $line = <$module>;
-                $process_opts .= $line
-            } while ($line !~ m/\A\Q$ws_prefix\E\}/);
-            $process_opts .= "${ws_prefix}break;\n\n";
-
-            $enum .= "    $opt,\n";
-        }
-        elsif ($line =~ m{\A\Q$ws_prefix\Eelse *\n?\z}ms)
-        {
-            $find_prefix .= $line;
-            do
-            {
-                $line = <$module>;
-                $find_prefix .= $line;
-            } while ($line !~ m/\A\Q$ws_prefix\E\}/);
-        }
-    }
-    elsif ($in)
-    {
-        $in = 0;
-
-        $text_out .= "$ws_prefix/* OPT-PARSE-START */\n";
-        $text_out .= $find_prefix;
-        $text_out .= "\n\n";
-        $text_out .= "${ws_prefix}switch (opt)\n${ws_prefix}{\n$process_opts\n$ws_prefix}\n";
-        $text_out .= "$ws_prefix/* OPT-PARSE-END */\n";
-
-        # Avoid an off-by-one error.
-        $text_out .= $line;
-    }
-    else
-    {
-        $text_out .= $line;
-    }
-}
-close($module);
-
-open my $out, ">", $module_filename;
-print {$out} $text_out;
-close($out);
-
-open my $enum_fh, ">", "cmd_line_enum.h";
-print {$enum_fh} $enum, "\n};\n";
-close($enum_fh);
-

fc-solve/source/scripts/gen_presets.pl

+#!/usr/bin/perl -w
+
+use strict;
+
+my %presets =
+(
+    'bakers_game' => [ qw(i freecell sbb suit) ],
+    'bakers_dozen' => [ qw(s 13 f 0 d 1 sbb rank sm limited esf none to 0123456789 at 0123456789) ],
+    'beleaguered_castle' => [ qw(i freecell sbb rank f 0) ],
+    'cruel' => [ qw(i bakers_dozen s 12 sbb suit) ],
+    'der_katzenschwanz' => [ qw(i die_schlange sm unlimited) ],
+    'die_schlange' => [ qw(i freecell f 8 s 9 d 2 esf none) ],
+    'eight_off' => [ qw(i kings_only_bakers_game f 8) ],
+    'fan' => [ qw(i freecell s 18 sbb suit sm limited esf kings_only f 0) ],
+    'forecell' => [ qw(i freecell esf kings_only) ],
+    'freecell' => [ qw(s 8 f 4 d 1 sbb ac sm limited esf any_card to [01][23456789] at 0123456789) ],
+    'good_measure' => [ qw(i bakers_dozen s 10) ],
+    'kings_only_bakers_game' => [ qw(i bakers_game esf kings_only) ],
+    'relaxed_freecell' => [ qw(i freecell sm unlimited) ],
+    'relaxed_seahaven_towers' => [ qw(i seahaven_towers sm unlimited) ],
+    'seahaven_towers' => [ qw(i bakers_game esf kings_only s 10) ],
+    'simple_simon' => [ qw(i bakers_game s 10 f 0 to abcdefgh at abcdefgh) ],
+    # 'yukon' => [ qw(i freecell s 7 f 0 to ABCDEFG) ],
+);
+
+my @strings;
+
+sub compile_preset
+{
+    my $preset_name = shift;
+
+    my $preset = $presets{$preset_name};
+
+    # For inheritance
+    my $compiled = shift || {};
+
+    my @params = @{$preset};
+
+    my ($cmd, $arg);
+
+    eval {
+
+    while ($cmd = shift(@params))
+    {
+        $arg = shift(@params);
+
+        if ($cmd =~ /^(i|inherits?)$/)
+        {
+            if (!exists($presets{$arg}))
+            {
+                die "Unknown inheritor!\n";
+            }
+            compile_preset($arg, $compiled);
+        }
+        elsif ($cmd =~ /^(s|stacks?)$/)
+        {
+            if ($arg !~ /^(\d+)$/)
+            {
+                die "Argument to stacks is not an integer!\n";
+            }
+            $compiled->{'stacks'} = $arg;
+        }
+        elsif ($cmd =~ /^(f|freecells?)$/)
+        {
+            if ($arg !~ /^(\d+)$/)
+            {
+                die "Argument to freecells is not an integer!\n";
+            }
+            $compiled->{'freecells'} = $arg;
+        }
+        elsif ($cmd =~ /^(d|decks?)$/)
+        {
+            if ($arg !~ /^(1|2)$/)
+            {
+                die "Argument to decks is not 1 or 2!\n";
+            }
+            $compiled->{'decks'} = $arg;
+        }
+        elsif ($cmd =~ /^(sbb|seqs_build_by)$/)
+        {
+            if ($arg !~ /^(ac|suit|rank)$/)
+            {
+                die "Argument to stacks_build_by is improper!\n";
+            }
+            $compiled->{'seqs_build_by'} = $arg;
+        }
+        elsif ($cmd =~ /^(sm|(seq|sequence)_move)$/)
+        {
+            if ($arg !~ /^(limited|unlimited)$/)
+            {
+                die "Argument to sequence move is not limited/unlimited!\n";
+            }
+            $compiled->{'sequence_move'} = (($arg eq "unlimited")?1:0);
+        }
+        elsif ($cmd =~ /^(esf|empty_stacks_fill(ed(_by)?)?)$/)
+        {
+            if ($arg !~ /^(any_card|kings_only|none)$/)
+            {
+                die "Improper parameter to Empty Stacks Filled By!\n";
+            }
+            $compiled->{'empty_stacks_fill'} = $arg;
+        }
+        elsif ($cmd =~ /^(to|tests_order)$/)
+        {
+            if ($arg =~ /[^0-9a-hA-G\[\(\)\]]/)
+            {
+                die "Unrecognized character in Tests order!\n";
+            }
+            $compiled->{'tests_order'} = $arg;
+        }
+        elsif ($cmd =~ /^(at|allowed_tests)$/)
+        {
+            if ($arg =~ /[^0-9a-hA-G]/)
+            {
+                die "Unrecognized character in Allowed Tests!\n";
+            }
+            $compiled->{'allowed_tests'} = $arg;
+        }
+        else
+        {
+            die "Unknown Command $cmd\n";
+        }
+    }
+
+    };
+
+    if ($@)
+    {
+        die "Preset Name: $preset_name\n$@";
+    }
+
+    return $compiled;
+}
+
+sub preset_to_string
+{
+    my $preset_name = shift;
+    my $pc = shift;
+
+    my @lines = ();
+
+    my $arg;
+
+    eval
+    {
+
+    push @lines, ("FCS_PRESET_" . uc($preset_name));
+
+    if (!exists($pc->{'freecells'}))
+    {
+        die "Freecells were not defined!\n";
+    }
+    push @lines, $pc->{'freecells'};
+
+    if (!exists($pc->{'stacks'}))
+    {
+        die "Stacks were not defined!\n";
+    }
+    push @lines,  $pc->{'stacks'};
+
+    if (!exists($pc->{'decks'}))
+    {
+        die "Decks Number was not defined!\n";
+    }
+    push @lines,  $pc->{'decks'};
+
+    if (!exists($pc->{'seqs_build_by'}))
+    {
+        die "Seqs Build by was not defined!\n";
+    }
+    $arg = $pc->{'seqs_build_by'};
+    push @lines, ("FCS_SEQ_BUILT_BY_". (($arg eq "ac") ? "ALTERNATE_COLOR" : ($arg eq "suit") ? "SUIT" : "RANK"));
+
+    if (!exists($pc->{'sequence_move'}))
+    {
+        die "Sequence move was not defined!\n";
+    }
+    push @lines, $pc->{'sequence_move'};
+
+    if (!exists($pc->{'empty_stacks_fill'}))
+    {
+        die "Empty Stacks Fill is undefined!\n";
+    }
+    $arg = $pc->{'empty_stacks_fill'};
+    push @lines, "FCS_ES_FILLED_BY_" . (($arg eq "none") ? "NONE" : ($arg eq "any_card") ? "ANY_CARD" : "KINGS_ONLY");
+
+    if (!exists($pc->{'tests_order'}))
+    {
+        die "Tests order is undefined!\n";
+    }
+    push @lines, "\"" . $pc->{'tests_order'} . "\"";
+
+    if (!exists($pc->{'allowed_tests'}))
+    {
+        die "Allowed Tests' is undefined!\n";
+    }
+    push @lines, "\"" . $pc->{'allowed_tests'} . "\"";
+
+    };
+
+    if ($@)
+    {
+        die "Preset name: $preset_name\n$@\n";
+    }
+
+    my @lines_p = (map { "        $_," } @lines);
+    my @lines_with_spaces = (@lines_p[0 .. 3], "", @lines_p[4 .. 6], "", @lines_p[7 .. $#lines_p]);
+
+    return "    {\n" . join("\n", @lines_with_spaces) . "\n" . "    },\n";
+}
+
+sub preset_to_docbook_string
+{
+    my $preset_name = shift;
+    my $pc = shift;
+    my @lines;
+
+    push @lines, join(" ", (map { ucfirst($_) } split(/_/, $preset_name)));
+
+    push @lines, ($pc->{'stacks'}, $pc->{'freecells'}, $pc->{'decks'});
+
+    my $sbb = $pc->{'seqs_build_by'};
+    push @lines,
+        (($sbb eq "ac") ? "Alternate Colour" :
+            ($sbb eq "suit") ? "Suit" :
+            "Rank");
+
+    my $arg = $pc->{'empty_stacks_fill'};
+    push @lines, (($arg eq "none") ? "None" : ($arg eq "any_card") ? "Any Card" : "Kings Only");
+
+    push @lines, ($pc->{'sequence_move'} ? "Limited" : "Unlimited");
+
+    return join("", map { "    <entry>$_</entry>\n" } @lines);
+}
+
+
+sub preset_to_perl_module
+{
+    my $preset_name = shift;
+    my $pc = shift;
+
+    my %sbb_map =
+    (
+        'ac' => "alt_color",
+        'suit' => "suit",
+        'rank' => "rank",
+    );
+
+    my $sbb = $sbb_map{$pc->{'seqs_build_by'}}
+        or die "Hoola";
+
+    my %esf_map =
+    (
+        'kings_only' => "kings",
+        'none' => "none",
+        'any_card' => "any",
+    );
+    my $esf = $esf_map{$pc->{'empty_stacks_fill'}}
+        or die "BlahBlajjor";
+
+    my $seq_move = $pc->{sequence_move} ? "unlimited" : "limited";
+
+    return <<"EOF";
+    "$preset_name" =>
+        Games::Solitaire::Verify::VariantParams->new(
+            {
+                'num_decks' => $pc->{decks},
+                'num_columns' => $pc->{stacks},
+                'num_freecells' => $pc->{freecells},
+                'sequence_move' => "$seq_move",
+                'seq_build_by' => "$sbb",
+                'empty_stacks_filled_by' => "$esf",
+            }
+        ),
+EOF
+}
+
+sub preset_to_pod
+{
+    my $preset_name = shift;
+    my $pc = shift;
+
+    return "=item * $preset_name\n\n";
+}
+
+my $mode = "c";
+
+my $mode_arg = shift(@ARGV);
+
+if ($mode_arg eq "--docbook")
+{
+    $mode = "docbook";
+}
+elsif ($mode_arg eq "--perlmod")
+{
+    $mode = "perl-mod";
+}
+elsif ($mode_arg eq "--pod")
+{
+    $mode = "pod";
+}
+
+my %mode_callbacks =
+(
+    "c" => \&preset_to_string,
+    "docbook" => \&preset_to_docbook_string,
+    "perl-mod" => \&preset_to_perl_module,
+    "pod" => \&preset_to_pod,
+);
+
+foreach my $preset_name (sort {$a cmp $b } keys(%presets))
+{
+    if (($mode ne "c") && ($preset_name eq "simple_simon"))
+    {
+        next;
+    }
+
+    my $preset_compiled = compile_preset($preset_name);
+    push @strings, $mode_callbacks{$mode}->($preset_name, $preset_compiled);
+}
+
+if ($mode eq "docbook")
+{
+    print join("", map { "<row>\n$_</row>\n" } @strings);
+}
+elsif ($mode eq "c")
+{
+    print "static const fcs_preset_t fcs_presets[" . scalar(@strings) . "] = \n";
+    print "{\n";
+    print join("", @strings);
+    print "};\n";
+}
+elsif ($mode eq "perl-mod")
+{
+    print "my %variants_map =\n";
+    print "(\n";
+    print join("", @strings);
+    print ");\n";
+}
+elsif ($mode eq "pod")
+{
+    print "=head1 PARAMETERS\n\n";
+
+    print "=head2 Variants IDs\n\n";
+
+    print "This is a list of the available variant IDS.\n\n";
+
+    print "=over 4\n\n";
+
+    print join("",@strings);
+
+    print "=back\n\n";
+}

fc-solve/source/scripts/old/gen_makefile.pl

+#!/usr/bin/perl
+
+use strict;
+
+sub min
+{
+    my $ret = shift;
+    foreach (@_)
+    {
+        if ($_ < $ret)
+        {
+            $ret = $_;
+        }
+    }
+
+    return $ret;
+}
+
+my @objects=(
+    qw(alloc app_str caas card cl_chop cmd_line fcs_dm fcs_hash fcs_isa),
+    qw(freecell intrface lib lookup2 move pqueue preset rand),
+    qw(scans simpsim state)
+    );
+
+my @targets = (
+    {
+        'exe' => "fc-solve",
+        'objs' => [ qw(main) ],
+    },
+    {
+        'exe' => "freecell-solver-range-parallel-solve",
+        'objs' => [ qw(test_multi_parallel) ],
+    },
+);
+
+my @headers_proto=
+    (
+        qw(alloc app_str caas card cl_chop), { 'name' => "config", 'gen' => 1},
+            qw(fcs_cl fcs fcs_dm fcs_enums),
+        qw(fcs_hash fcs_isa fcs_move fcs_user inline jhjtypes lookup2),
+        qw(move ms_ca), {'name' => "prefix", 'gen' => 1},
+            qw(pqueue preset rand state test_arr tests)
+    );
+
+my @headers = (map { ref($_) eq "HASH" ? $_->{'name'} : $_ } @headers_proto);
+
+my @defines=(qw(WIN32));
+
+my @debug_defines = (qw(DEBUG));
+
+print "all: fc-solve.exe freecell-solver-range-parallel-solve.exe\n\n";
+
+print "OFLAGS=" . "/Og2 " . join(" ", (map { "/D".$_ } @defines)) . "\n";
+print "DFLAGS=\$(OFLAGS) " . join(" ", (map { "/D".$_ } @debug_defines)) . "\n";
+
+print "INCLUDES=" . join(" ", (map { $_.".h" } @headers)). "\n";
+print "CC=cl\n";
+print "LIB32=link.exe\n";
+
+
+print "\n\n";
+
+print "OBJECTS = " . join(" ", (map { $_.".obj" } @objects)) . "\n";
+
+print "\n\n";
+
+foreach my $o (@objects, (map { @{$_->{'objs'}} } @targets))
+{
+    print "$o.obj: $o.c \$(INCLUDES)\n";
+    print "\t\$(CC) /c /Fo$o.obj \$(OFLAGS) $o.c\n";
+    print "\n";
+}
+
+print "\n\n###\n### Final Targets\n###\n\n\n";
+
+foreach my $t (@targets)
+{
+    my $exe = $t->{'exe'};
+    my @objs = @{$t->{'objs'}};
+
+    #my $obj_line = "\$(OBJECTS) " . join(" ", (map { "$_.obj" } @objs));
+    my $obj_line = "freecell-solver-static.lib " . join(" ", (map { "$_.obj" } @objs));
+
+    print "$exe.exe: $obj_line\n";
+    print "\t\$(CC) /Fe$exe.exe /F0x2000000 $obj_line\n";
+    print "\n";
+}
+
+print "freecell-solver-static.lib: \$(OBJECTS)\n";
+print "\t\$(LIB32) -lib \$(OBJECTS) /out:freecell-solver-static.lib\n";
+print "\n";
+
+print "freecell-solver.dll: \$(OBJECTS) freecell-solver.def\n";
+print "\t\$(LIB32) kernel32.lib user32.lib gdi32.lib /dll /out:freecell-solver.dll /implib:freeecell-solver.lib /DEF:freecell-solver.def \$(OBJECTS) \n";
+print "\n";
+
+#print "fc-solve.exe: \$(OBJECTS)\n";
+#print "\t\$(CC) /Fefc-solve.exe /F0x2000000 \$(OBJECTS)\n";
+#print "\n";
+
+print "clean:\n";
+print "\tdel *.obj *.exe *.lib *.dll *.exp\n";
+
+open I, "<Makefile.am";
+open O, ">Makefile.am.new";
+while (<I>)
+{
+    if (/^libfreecell_solver_la_SOURCES *=/)
+    {
+        print O "libfreecell_solver_la_SOURCES = " . join(" ", (map { "$_.c" } @objects)) . "\n";
+    }
+    elsif (/^#<<<HEADERS\.START/)
+    {
+        while(! /^#>>>HEADERS\.END/)
+        {
+            $_ = <I>;
+        }
+        print O "#<<<HEADERS.START\n";
+        my @headers_no_gen = map { (ref($_) eq "HASH") ? $_->{'name'} : $_ } (grep { (ref($_) eq "HASH") ? (! $_->{'gen'}) : 1 } @headers_proto);
+        for my $i (0 .. ((int(scalar(@headers_no_gen)/5)+((scalar(@headers_no_gen)%5) > 0))-1))
+        {
+            print O "EXTRA_DIST += " . join(" ", map { "$_.h" } @headers_no_gen[($i*5) .. min($i*5+4, $#headers_no_gen)]) . "\n";
+        }
+        print O "#>>>HEADERS.END\n";
+    }
+    else
+    {
+        print O $_;
+    }
+}
+close(O);
+close(I);
+rename("Makefile.am.new", "Makefile.am");
+
+open I, "<Makefile.gnu";
+open O, ">Makefile.gnu.new";
+while(<I>)
+{
+    if (/^#<<<OBJECTS\.START/)
+    {
+        while(! /^#>>>OBJECTS\.END/)
+        {
+            $_ = <I>;
+        }
+        print O "#<<<OBJECTS.START\n";
+        print O "OBJECTS = " . (" " x 20) . "\\\n";
+        print O join("", (map { sprintf((" " x 10) . "%-20s\\\n", ($_.".o")) } @objects));
+        print O "\n";
+        print O "#>>>OBJECTS.END\n";
+    }
+    else
+    {
+        print O $_;
+    }
+}
+close(O);
+close(I);
+rename("Makefile.gnu.new", "Makefile.gnu");
+
+open I, "<Makefile.lite";
+open O, ">Makefile.lite.new";
+while(<I>)
+{
+    if (/^INCLUDES *=/)
+    {
+        print O "INCLUDES = " . join(" ", (map { "$_.h" } @headers)) . "\n";
+    }
+    elsif (/^#<<<OBJECTS\.START/)
+    {
+        while(! /^#>>>OBJECTS\.END/)
+        {
+            $_ = <I>;
+        }
+        my @ext_objects = (@objects, "main");
+        print O "#<<<OBJECTS.START\n";
+        print O join("\n\n", (map { "$_.o: $_.c \$(INCLUDES)\n\t\$(CC) -c \$(OFLAGS) -o \$@ \$<" } @ext_objects));
+        print O "\n\nOBJECTS = " . join(" ", (map { "$_.o" } @ext_objects)) . "\n";
+        print O "#>>>OBJECTS.END\n";
+    }
+    else
+    {
+        print O $_;
+    }
+}
+close(O);
+close(I);
+rename("Makefile.lite.new", "Makefile.lite");
+

fc-solve/source/scripts/old/prepare-for-cmd-line-radix-tree.pl

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use List::Util qw(first);
+
+my $text_out;
+my $find_prefix;
+my $process_opts = "";
+my $enum = "enum FCS_COMMAND_LINE_OPTIONS\n{\n";
+my $text_in = "";
+my $ws_prefix;
+my $in = 0;
+
+my $module_filename = "cmd_line.c";
+open my $module, "<", $module_filename;
+while (my $line = <$module>)
+{
+    if (($line =~ m{\A(\s*)/\* OPT-PARSE-START \*/})
+           ..
+        ($line =~ m{/\* OPT-PARSE-END \*/})
+    )
+    {
+        $in = 1;
+        if (!defined($ws_prefix))
+        {
+            $ws_prefix = $1;
+        }
+
+        my $inner_strcmp_regex = qr{!strcmp *\( *argv\[arg\] *, *"-[a-zA-Z\-]+" *\) *};
+        my $strcmp_regex = qr{\($inner_strcmp_regex\)|$inner_strcmp_regex};
+
+        my $complete_strcmp = ($line =~ m{\A\Q$ws_prefix\Eelse if \((?:$strcmp_regex *\|\| *)*$strcmp_regex\) *\n?\z}ms);
+
+        my $is_start_line = ($line =~ m{\A\Q$ws_prefix\Eelse if \( *\n?\z}ms);
+        if ($complete_strcmp || $is_start_line)
+        {
+            if ($is_start_line)
+            {
+                NEXT_LINE_LOOP:
+                while (my $next_line = <$module>)
+                {
+                    $line .= $next_line;
+                    if ($next_line =~ m{\A\Q$ws_prefix\E *\) *\n?\z})
+                    {
+                        last NEXT_LINE_LOOP;
+                    }
+                }
+            }
+            my @strings = ($line =~ m{"([^"]+)"}g);
+            my $first = first { m{\A--} } @strings;
+            if (!defined($first))
+            {
+                $first = $strings[0];
+            }
+
+            $first =~ s{\A-*}{};
+            $first =~ tr{-}{_};
+            my $opt = "FCS_OPT_" . uc($first);
+
+            my $indent = "        ";
+            $find_prefix .= join("",
+                map { $indent. $_ . "\n" }
+                (
+                    ("else if (" . join("||", map { qq{(!strcmp(argv[arg], "$_"))} } @strings) . ")"),
+                    "{",
+                    "    opt = $opt;",
+                    "}"
+                )
+            );
+
+            $process_opts .= "${ws_prefix}case ${opt}: /* STRINGS=" . join("|", @strings) . ";" . " */\n";
+
+            do
+            {
+                $line = <$module>;
+                $process_opts .= $line
+            } while ($line !~ m/\A\Q$ws_prefix\E\}/);
+            $process_opts .= "${ws_prefix}break;\n\n";
+
+            $enum .= "    $opt,\n";
+        }
+        elsif ($line =~ m{\A\Q$ws_prefix\Eelse *\n?\z}ms)
+        {
+            $find_prefix .= $line;
+            do
+            {
+                $line = <$module>;
+                $find_prefix .= $line;
+            } while ($line !~ m/\A\Q$ws_prefix\E\}/);
+        }
+    }
+    elsif ($in)
+    {
+        $in = 0;
+
+        $text_out .= "$ws_prefix/* OPT-PARSE-START */\n";
+        $text_out .= $find_prefix;
+        $text_out .= "\n\n";
+        $text_out .= "${ws_prefix}switch (opt)\n${ws_prefix}{\n$process_opts\n$ws_prefix}\n";
+        $text_out .= "$ws_prefix/* OPT-PARSE-END */\n";
+
+        # Avoid an off-by-one error.
+        $text_out .= $line;
+    }
+    else
+    {
+        $text_out .= $line;
+    }
+}
+close($module);
+
+open my $out, ">", $module_filename;
+print {$out} $text_out;
+close($out);
+
+open my $enum_fh, ">", "cmd_line_enum.h";
+print {$enum_fh} $enum, "\n};\n";
+close($enum_fh);
+