1. Shlomi Fish
  2. fc-solve

Commits

Shlomi Fish  committed 089a956

Add the --show-extended-limits flag.

This makes the output less ambiguous in case the state is intractable.

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

  • Participants
  • Parent commits bc66a49
  • Branches master

Comments (0)

Files changed (5)

File fc-solve/source/NEWS.txt

View file
 :Date: 2009-09-05
 :Revision: $Id$
 
+1. Add the +--show-exceeded-limits+ / +-sel+ flag that removes ambiguity
+in the output.
+
 Version 3.10.0: (15-Jan-2012)
 -----------------------------
 

File fc-solve/source/USAGE.txt

View file
 $ fc-solve --output 2405.solution.txt 2405.board
 ----------------------
 
+-sel , --show-exceeded-limits
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This option will display a different status message ("Iterations count
+exceeded.") instead of "I could not solve this game." in case the iterations
+count was exceeded. This is recommended because the "I could not solve this
+game." message can also mean that the entire game graph was fully traversed
+(within the limitations of the specified moves' types) and so no solution
+is possible.
+
+This option is not the default, to retain compatibility with previous versions
+of Freecell Solver and was added in version 3.12.0 of fc-solve.
+
 Game Variants Options
 ---------------------
 

File fc-solve/source/main.c

View file
     void * context
     )
 {
+    /* TODO: Put argv[arg] in a variable. */
     fc_solve_display_information_context_t * dc;
     *num_to_skip = 0;
 
     {
         dc->display_parent_iter_num = TRUE;
     }
+    else if ((!strcmp(argv[arg], "-sel")) || (!strcmp(argv[arg], "--show-exceeded-limits")))
+    {
+        dc->show_exceeded_limits = TRUE;
+    }
     else if ((!strcmp(argv[arg], "--reset")))
     {
         init_debug_context(dc);
     "-snx", "--standard-notation-extended",
     "-sam", "--display-states-and-moves",
     "-pi", "--display-parent-iter",
+    "-sel", "--show-exceeded-limits",
     "-o", "--output",
     "--reset",
     "--version",

File fc-solve/source/output_to_file.h

View file
     fcs_bool_t debug_iter_output_on;
     fcs_bool_t display_moves;
     fcs_bool_t display_states;
+    fcs_bool_t show_exceeded_limits;
     int standard_notation;
     const char * output_filename;
 };
     dc->display_states = TRUE;
     dc->standard_notation = STANDARD_NOTATION_NO;
     dc->output_filename = NULL;
+    dc->show_exceeded_limits = FALSE;
 
     return;
 }
 
         fprintf(output_fh, "This game is solveable.\n");
     }
+    else if (debug_context.show_exceeded_limits && (ret == FCS_STATE_SUSPEND_PROCESS))
+    {
+        fprintf(output_fh, "Iterations count exceeded.\n");
+    }
     else
     {
         fprintf (output_fh, "I could not solve this game.\n");

File fc-solve/source/t/t/fc-solve-output.t

View file
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+use Carp;
+use Data::Dumper;
+use String::ShellQuote;
+use File::Spec;
+
+sub trap_board
+{
+    local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+    my $args = shift;
+
+    my $board = $args->{board};
+    my $deal = $args->{deal};
+    my $msdeals = $args->{msdeals};
+
+    if (! defined($board))
+    {
+        if (!defined($deal))
+        {
+            confess "Neither Deal nor board are specified";
+        }
+        if ($deal !~ m{\A[1-9][0-9]*\z})
+        {
+            confess "Invalid deal $deal";
+        }
+    }
+
+    my $theme = $args->{theme} || ["-l", "gi"];
+
+    my $variant = $args->{variant}  || "freecell";
+    my $is_custom = ($variant eq "custom");
+    my $variant_s = $is_custom ? "" : "-g $variant";
+
+    my $fc_solve_exe = shell_quote($ENV{'FCS_PATH'} . "/fc-solve");
+
+    open my $fc_solve_output,
+        ($msdeals ?
+            "pi-make-microsoft-freecell-board $deal | " :
+            ($board ? "" : "make_pysol_freecell_board.py $deal $variant | ")
+        ) .
+        "$fc_solve_exe $variant_s " . shell_quote(@$theme) . " -p -t -sam " .
+        ($board ? shell_quote($board) : "") .
+        " |"
+        or Carp::confess "Error! Could not open the fc-solve pipeline";
+
+    my @lines = <$fc_solve_output>;
+
+    close($fc_solve_output);
+
+    return { out_lines => \@lines };
+}
+
+{
+    my $fc_solve_output = trap_board({ deal => 1941, theme => ['--show-exceeded-limits', '--max-iters', '10'], });
+
+    my $output_text = join('', @{$fc_solve_output->{out_lines}});
+
+    # TEST
+    like(
+        $output_text,
+        qr/
+            ^Iterations\ count\ exceeded\.\n
+            Total\ number\ of\ states\ checked\ is\ 10\.\n
+        /msx,
+        "Checking that --show-exceeded-limits is working properly.",
+    );
+}
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (c) 2008 Shlomi Fish
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+=cut
+