
APT.all-test.water-jug.water-jug-tie.pour.soar Maven / Gradle / Ivy
# If the task is water-jug and there is a jug that is not full and the other jug is not empty,
# then propose pouring water from the second jug into the first jug.
sp {water-jug*propose*pour
(state ^name water-jug
^jug { <> })
( ^contents > 0 )
( ^empty > 0)
-->
( ^operator +)
( ^name pour
^empty-jug
^fill-jug )}
# If the task is water-jug and the pour operator is selected,
# and the contents of the jug being emptied are less than or equal to
# the empty amount of the jug being filled,
# then set the contents of the jug being emptied to 0;
# set the contents of the jug being filled to the sum of the two jugs.
sp {water-jug*apply*pour*not-empty-source
(state ^name water-jug
^operator )
( ^name pour
^empty-jug
^fill-jug )
( ^volume
^contents
^empty )
( ^volume
^contents { <= })
-->
( ^contents 0 -)
( ^contents (+ ) - )}
# If the task is water-jug and the pour operator is selected, and
# the contents of the jug being emptied are greater than the empty amount
# of the jug being filled,
# then set the contents of the jug being emptied to its contents minus the
# empty of the jug being filled;
# set the contents of the jug filled to its volume.
sp {water-jug*apply*pour*empty-source
(state ^name water-jug
^operator )
( ^name pour
^empty-jug
^fill-jug )
( ^volume
^contents { > })
( ^volume
^contents
^empty )
-->
( ^contents (- ) - )
( ^contents -)}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy