switch over to storing rspace+ss as decision list
Matt S Trout [Sat, 31 Mar 2018 18:59:13 +0000 (18:59 +0000)]
lib/DX/SearchProcess.pm
lib/DX/SearchState.pm
lib/DX/Step/Backtrack.pm
lib/DX/Step/EnterRecheck.pm
lib/DX/Step/ResolveProposition.pm
lib/DX/Types.pm

index e2ec2d5..e22eaa3 100644 (file)
@@ -6,7 +6,7 @@ use DX::Class;
 has current_search_state => (
   is => 'ro', isa => SearchState, required => 1,
   handles => [ qw(
-    current_hypothesis next_step propositions adjustments_made
+    current_hypothesis next_step propositions
   ) ],
 );
 
index bb0cb10..8b08596 100644 (file)
@@ -12,7 +12,7 @@ has next_step => (is => 'ro', isa => Maybe[Step], required => 1);
 
 has propositions => (is => 'ro', isa => PropositionSequence, required => 1);
 
-has adjustments_made => (is => 'ro', isa => AdjustmentList, required => 1);
+has decisions_taken => (is => 'ro', isa => DecisionList, required => 1);
 
 has is_solution_state => (is => 'ro', isa => Bool, required => 1);
 
@@ -32,7 +32,7 @@ sub new_for {
   my ($class, $hyp, $props) = @_;
   $class->new(
     current_hypothesis => $hyp,
-    adjustments_made => [],
+    decisions_taken => [],
     propositions => $props,
     (@{$props->members}
       ? (
index d14ca2f..f693c49 100644 (file)
@@ -7,11 +7,11 @@ with 'DX::Role::Step';
 sub apply_to {
   my ($self, $ss) = @_;
   trace backtrack => [ statement => [ [ symbol => 'backtrack' ] ] ];
-  foreach my $adj (@{$ss->adjustments_made}) {
-    my ($step_was, $ss_was) = @$adj;
-    if (my $alt = $step_was->alternative_step) {
-      return $ss_was->but(next_step => $alt);
-    }
+  foreach my $adj (@{$ss->decisions_taken}) {
+    my ($rspace_was, $ss_was) = @$adj;
+    return $ss_was->but(
+      next_step => $rspace_was->remaining_resolution_space->next_step
+    );
   }
   return $ss->but(next_step => $ss->on_exhaustion_step);
 }
index f0fffd1..d2d44ba 100644 (file)
@@ -57,7 +57,7 @@ sub apply_to {
 
   my $ss = DX::SearchState->new(
     current_hypothesis => $hyp,
-    adjustments_made => [],
+    decisions_taken => [],
     propositions => $pseq,
     next_step => DX::Step::ConsiderProposition->new(
                    proposition => $prop,
index 3416c27..42b92dc 100644 (file)
@@ -93,13 +93,10 @@ sub apply_to {
   };
   my $ss = $old_ss->but(
     next_step => $ns,
-    (@{$self->actions}
-      ? (adjustments_made => [
-          [ $self, $old_ss ],
-          @{$old_ss->adjustments_made}
-        ])
-      : ()
-    ),
+    decisions_taken => [
+      [ $self->resolution_space, $old_ss ],
+      @{$old_ss->decisions_taken}
+    ],
   );
   my $new_ss = $self->_apply_to_ss($ss);
   return $ss->but(next_step => DX::Step::Backtrack->new) unless $new_ss;
index 3434bb2..b34565b 100644 (file)
@@ -36,7 +36,7 @@ class_type DictValue => { class => 'DX::Value::Dict' };
 
 declare PropositionList => as ArrayRef[Proposition];
 
-declare AdjustmentList => as ArrayRef[Tuple[Step, SearchState]];
+declare DecisionList => as ArrayRef[Tuple[ResolutionSpace, SearchState]];
 
 declare DependencyType => where {
   foreach my $cand (EXISTENCE_OF, TYPE_OF, INDICES_OF, CONTENTS_OF) {