1 package DX::SearchState;
3 use Types::Standard qw(Maybe Bool);
4 use DX::Step::Backtrack;
5 use DX::Step::ConsiderProposition;
6 use DX::Step::MarkAsSolution;
9 has current_hypothesis => (is => 'ro', isa => Hypothesis, required => 1);
11 has next_step => (is => 'ro', isa => Maybe[Step], required => 1);
13 has propositions => (is => 'ro', isa => PropositionSequence, required => 1);
15 has adjustments_made => (is => 'ro', isa => AdjustmentList, required => 1);
17 has is_solution_state => (is => 'ro', isa => Bool, required => 1);
19 has on_exhaustion_step => (is => 'ro', isa => Maybe[Step], required => 1);
21 has on_solution_step => (is => 'ro', isa => Maybe[Step], required => 1);
23 sub next_proposition {
25 my $hyp = $self->current_hypothesis;
26 $self->propositions->members->[
27 $hyp->resolved_propositions->resolved_count + 1
32 my ($class, $hyp, $props) = @_;
34 current_hypothesis => $hyp,
35 adjustments_made => [],
36 propositions => $props,
39 next_step => DX::Step::ConsiderProposition->new(
40 proposition => $props->members->[0],
42 is_solution_state => 0,
44 : ( next_step => undef, is_solution_state => 1 )
46 on_exhaustion_step => undef,
47 on_solution_step => DX::Step::MarkAsSolution->new,
53 return undef unless my $step = $self->next_step;
55 return $step->apply_to($self);
61 next_step => DX::Step::Backtrack->new,