Skip to content

Commit

Permalink
Experimental solving of a sequence of multiple boards files
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomif committed Feb 2, 2025
1 parent 1c4c624 commit b3065f2
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,36 +119,46 @@ sub run
}
);

$self->_set_up_solver( 0, [ 1, $RANK_KING ] );

my $verdict = 0;

$self->_next_task;

QUEUE_LOOP:
while ( my $state = $self->_get_next_state_wrapper )
my $global_verdict = 1;
foreach my $board_fn (@ARGV)
{
# The foundation
my $no_cards = 1;
my $verdict = 0;
$self->_calc_lines( $board_fn, );
$self->_set_up_solver( 0, [ 1, $RANK_KING ] );

my @_pending;
$self->_next_task;

if (1)
QUEUE_LOOP:
while ( my $state = $self->_get_next_state_wrapper )
{
$self->_find_moves( \@_pending, $state, \$no_cards );
# The foundation
my $no_cards = 1;

my @_pending;

if (1)
{
$self->_find_moves( \@_pending, $state, \$no_cards );
}

if ($no_cards)
{
$self->_trace_solution( $state, );
$verdict = 1;

# $self->_output_handle->print("END solved run\n");
last QUEUE_LOOP;
}
last QUEUE_LOOP
if not $self->_process_pending_items( \@_pending, $state );
}

if ($no_cards)
$self->_end_report( $verdict, );
if ( not $verdict )
{
$self->_trace_solution( $state, );
$verdict = 1;
last QUEUE_LOOP;
$global_verdict = 0;
}
last QUEUE_LOOP
if not $self->_process_pending_items( \@_pending, $state );
}

return $self->_my_exit( $verdict, );
return $self->_my_exit( $global_verdict, );
}

=head1 SEE ALSO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ sub get_max_num_played_cards
return $self->_maximal_num_played_cards__from_all_tasks() - 1;
}

sub _my_exit
sub _end_report
{
my ( $self, $verdict, ) = @_;
my $output_handle = $self->_output_handle;
Expand All @@ -273,9 +273,16 @@ sub _my_exit
);
}

return;
}

sub _my_exit
{
my ( $self, $verdict, ) = @_;

if ( defined( $self->_output_fn ) )
{
close($output_handle);
close( $self->_output_handle );
}

exit( !$verdict );
Expand Down Expand Up @@ -382,8 +389,9 @@ sub _process_cmd_line
{
my ( $self, $args ) = @_;

my $_max_iters_limit = ( 1 << 31 );
my $_num_foundations = 1;
my $_max_iters_limit = ( 1 << 31 );
my $_num_foundations = 1;
my $_prelude_string;
my $_should_show_maximal_num_played_cards = 0;
my $display_boards = '';
my $quiet = '';
Expand Down Expand Up @@ -423,7 +431,7 @@ sub _process_cmd_line
{
die "Invalid prelude string '$val' !";
}
$self->_prelude_string($val);
$_prelude_string = $val;
return;
},
"task-name=s" => sub {
Expand Down Expand Up @@ -478,6 +486,10 @@ sub _process_cmd_line
$self->_display_boards($display_boards);
$self->_max_iters_limit($_max_iters_limit);
$self->_num_foundations($_num_foundations);
if ( defined($_prelude_string) )
{
$self->_prelude_string($_prelude_string);
}
$self->_quiet($quiet);
$self->_should_show_maximal_num_played_cards(
$_should_show_maximal_num_played_cards);
Expand All @@ -493,12 +505,15 @@ sub _process_cmd_line
else
{
## no critic
open( $output_handle, ">&STDOUT" );
# open( $output_handle, ">&STDOUT" );
$output_handle = \*STDOUT;
## use critic
# die $output_handle;"applj";
}
$self->_output_fn($output_fn);
$self->_output_handle($output_handle);
$self->_calc_lines( shift(@ARGV) );

# $self->_calc_lines( shift(@ARGV) );

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ sub run
{
$place_queens_on_kings = 1;
}
$self->_calc_lines( shift(@ARGV), );

my $talon_line = shift( @{ $self->_board_lines } );
my @talon_values;
Expand Down

0 comments on commit b3065f2

Please sign in to comment.