eliminate vestigial force_backtrack methods
[scpubgit/DX.git] / lib / DX / SearchProcess.pm
CommitLineData
8c16d3c9 1package DX::SearchProcess;
2
3use DX::SearchState;
4use DX::Class;
5
6has current_search_state => (
7 is => 'ro', isa => SearchState, required => 1,
8 handles => [ qw(
1c02730b 9 current_hypothesis next_step propositions
8c16d3c9 10 ) ],
11);
12
13sub new_for {
14 my ($class, $hyp, $props) = @_;
15 $class->new(
8cc971ec 16 current_search_state => DX::SearchState->new_for($hyp, $props),
8c16d3c9 17 );
18}
19
20sub with_one_step {
21 my ($self) = @_;
22 my $new_ss = $self->current_search_state->with_one_step;
23 return undef unless $new_ss;
24 return $self->but(current_search_state => $new_ss);
25}
26
27sub find_solution {
28 my ($self) = @_;
29 my $state = $self->current_search_state;
282b1d76 30 while ($state and (not $state->is_solution_state)) {
8c16d3c9 31 $state = $state->with_one_step;
32 }
33 return undef unless $state;
8c16d3c9 34 return $self->but(current_search_state => $state);
35}
36
8c16d3c9 37sub find_next_solution {
38 my ($self) = @_;
ae6f4d03 39 my $state = $self->current_search_state->with_one_step;
40 return $self->but(current_search_state => $state)->find_solution;
8c16d3c9 41}
42
431;