AI-Pathfinding-OptimizeMultiple
view release on metacpan or search on metacpan
lib/AI/Pathfinding/OptimizeMultiple/IterState.pm view on Meta::CPAN
my $self = shift;
my $scans_data = $self->_main()->_scans_data();
my @dims = $scans_data->dims();
return $scans_data->slice(
join( ",", ":", $self->_scan_idx(), ( ("(0)") x ( @dims - 2 ) ) ) );
}
sub update_total_iters
{
my $state = shift;
# $r is the result of this scan.
my $r = $state->idx_slice();
# Add the total iterations for all the states that were solved by
# this scan.
$state->_main()
->_add_to_total_iters(
lib/AI/Pathfinding/OptimizeMultiple/IterState.pm view on Meta::CPAN
# yet.
$state->_main()
->_add_to_total_iters( $indexes->nelem() * $state->_quota() );
# Keep only the states that have not been solved yet.
$state->_main()
->_scans_data(
$state->_main()->_scans_data()->dice( $indexes, "X" )->copy() );
}
sub update_idx_slice
{
my $state = shift;
my $r = $state->idx_slice()->copy();
# $r cannot be 0, because the ones that were 0, were already solved
# in $state->update_total_iters().
my $idx_slice = $state->idx_slice();
$idx_slice .=
( ( $r > 0 ) * ( $r - $state->_quota() ) ) + ( ( $r < 0 ) * ($r) );
}
( run in 0.258 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )