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 on_exhaustion_step => (is => 'ro', isa => Maybe[Step], required => 1);
20 has on_solution_step => (is => 'ro', isa => Maybe[Step], required => 1);
22 sub next_proposition {
24 my $hyp = $self->current_hypothesis;
25 $self->propositions->members->[
26 $hyp->resolved_propositions->resolved_count + 1
31 my ($class, $hyp, $props) = @_;
33 current_hypothesis => $hyp,
34 decisions_taken => [],
35 propositions => $props,
38 next_step => DX::Step::ConsiderProposition->new(
39 proposition => $props->members->[0],
41 is_solution_state => 0,
43 : ( next_step => undef, is_solution_state => 1 )
45 on_exhaustion_step => undef,
46 on_solution_step => DX::Step::MarkAsSolution->new,
52 return undef unless my $step = $self->next_step;
54 return $step->apply_to($self);
60 next_step => DX::Step::Backtrack->new,