1 package DX::SearchState;
3 use DX::Step::Backtrack;
4 use DX::Step::ConsiderProposition;
5 use DX::Step::MarkAsSolution;
8 has current_hypothesis => (is => 'ro', isa => Hypothesis, required => 1);
10 has next_step => (is => 'ro', isa => Maybe[Step], required => 1);
12 has propositions => (is => 'ro', isa => PropositionSequence, required => 1);
14 has decisions_taken => (is => 'ro', isa => DecisionList, required => 1);
16 has is_solution_state => (is => 'ro', isa => Bool, required => 1);
18 has is_exhaustion_state => (is => 'ro', isa => Bool, required => 1);
20 has on_exhaustion_step => (is => 'ro', isa => Maybe[Step], required => 1);
22 has on_solution_step => (is => 'ro', isa => Maybe[Step], required => 1);
24 sub next_proposition {
26 my $hyp = $self->current_hypothesis;
27 $self->propositions->members->[
28 $hyp->resolved_propositions->resolved_count + 1
33 my ($class, $hyp, $props) = @_;
35 current_hypothesis => $hyp,
36 decisions_taken => [],
37 propositions => $props,
40 next_step => DX::Step::ConsiderProposition->new(
41 proposition => $props->members->[0],
43 is_solution_state => 0,
45 : ( next_step => DX::Step::MarkAsExhaustion->new, is_solution_state => 1 )
47 is_exhaustion_state => 0,
48 on_exhaustion_step => DX::Step::MarkAsExhaustion->new,
49 on_solution_step => DX::Step::MarkAsSolution->new,
55 return undef unless my $step = $self->next_step;
57 return $step->apply_to($self);