cut over to next_proposition using resolved_count
Matt S Trout [Sat, 2 Apr 2016 21:50:53 +0000 (21:50 +0000)]
lib/DX/Hypothesis.pm
lib/DX/ResolvedPropositionSet.pm
lib/DX/SearchState.pm

index e8b66c0..95c05f3 100644 (file)
@@ -25,8 +25,6 @@ has action_applications => (
 
 has action_policy => (is => 'ro', isa => ActionPolicy, required => 1);
 
-sub head_proposition { shift->outstanding_propositions->[0] }
-
 sub with_actions {
   my ($self, @actions) = @_;
   my $hyp = $self;
index 73d6c63..357186b 100644 (file)
@@ -11,6 +11,8 @@ has propositions => (is => 'ro', isa => ArrayRef[Proposition], required => 1);
 
 has scope_depth => (is => 'ro', required => 1);
 
+sub resolved_count { scalar @{$_[0]->propositions} }
+
 sub new_empty {
   my ($class) = @_;
   $class->new(
index def236d..9c831df 100644 (file)
@@ -12,7 +12,12 @@ has propositions => (is => 'ro', isa => PropositionSequence, required => 1);
 
 has alternatives => (is => 'ro', isa => AlternativeList, required => 1);
 
-sub next_proposition { $_[0]->current_hypothesis->head_proposition }
+sub next_proposition {
+  my ($self) = @_;
+  $self->propositions->members->[
+    $self->current_hypothesis->resolved_propositions->resolved_count
+  ];
+}
 
 sub new_for {
   my ($class, $hyp, $props) = @_;
@@ -20,7 +25,7 @@ sub new_for {
     current_hypothesis => $hyp,
     alternatives => [],
     next_step => DX::Step::InvokeNextPredicate->new(
-      proposition => $hyp->head_proposition,
+      proposition => $props->members->[0],
     ),
     propositions => $props,
   );
@@ -60,7 +65,7 @@ sub with_one_step {
 
 sub find_solution {
   my $state = $_[0];
-  while ($state and @{$state->current_hypothesis->outstanding_propositions}) {
+  while ($state and $state->next_proposition) {
     $state = $state->with_one_step;
   }
   trace 'search.solution.hyp' => $state->current_hypothesis if $state;