Skip to content

Commit

Permalink
Implemented propagation of side effects in StateGoalEvaluation.kt ret…
Browse files Browse the repository at this point in the history
…urned end states, according to Conjunction pattern
  • Loading branch information
siboxd committed Jul 1, 2020
1 parent e968567 commit 3200a45
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package it.unibo.tuprolog.solve.solver.fsm.impl

import it.unibo.tuprolog.core.Struct
import it.unibo.tuprolog.solve.SideEffect
import it.unibo.tuprolog.solve.Solution
import it.unibo.tuprolog.solve.StreamsSolver
import it.unibo.tuprolog.solve.currentTimeInstant
Expand Down Expand Up @@ -41,9 +42,12 @@ internal class StateGoalEvaluation(
responses = StreamsSolver.solveToResponses(solve.newThrowSolveRequest(prologError))
}

var allSideEffectsSoFar = emptyList<SideEffect>()
responses?.forEach {

yield(ifTimeIsNotOver(stateEnd(it)))
allSideEffectsSoFar = allSideEffectsSoFar + it.sideEffects

yield(ifTimeIsNotOver(stateEnd(it.copy(sideEffects = allSideEffectsSoFar))))

if (it.solution is Solution.Halt) return@sequence // if halt reached, overall computation should stop
}
Expand Down

0 comments on commit 3200a45

Please sign in to comment.