Skip to content

Commit cb68ac9

Browse files
authored
Merge pull request #27 from AI-Planning/allow-condeff
Fixing the parsing to allow a condeff as a oneoff outcome.
2 parents 4ea7dcf + d687b75 commit cb68ac9

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

fondutils/determizer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
from pddl.action import Action
44
from pddl.core import Domain
55
from pddl.logic.base import OneOf, And, Not
6+
from pddl.logic.effects import When
67
from pddl.logic.predicates import Predicate
78
from pddl.requirements import Requirements
89

910

1011
from .normalizer import normalize_operator
1112

12-
DEBUG = False
13+
DEBUG = True
1314

1415

1516
def determinize(domain: Domain, dom_suffix: str = "ALLOUT", op_prefix: str = "_DETDUP_", op_suffix: str = "") -> Domain:
@@ -47,7 +48,7 @@ def determinize(domain: Domain, dom_suffix: str = "ALLOUT", op_prefix: str = "_D
4748
counter = 1
4849
for eff in new_act.effect.operands:
4950
assert isinstance(
50-
eff, (And, Predicate, Not)
51+
eff, (And, Predicate, Not, When)
5152
), f"Effect in OneOf is not an And effect: {eff}"
5253
new_actions.append(
5354
Action(

tests/domain_07.pddl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
;; multiple oneof cross product
2+
(define (domain blocks-domain)
3+
(:requirements :non-deterministic :equality :typing :adl)
4+
(:predicates
5+
(f1) (f2) (f3) (f13)
6+
)
7+
8+
(:action test
9+
:parameters ()
10+
:precondition (and (f13))
11+
:effect (oneof
12+
(when
13+
(f1)
14+
(f2))
15+
(f3)
16+
)
17+
)
18+
)

tests/domain_07_det.pddl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(define (domain blocks-domain)
2+
(:requirements :adl :equality :typing)
3+
(:predicates (f1) (f13) (f2) (f3))
4+
(:action test_DETDUP_1
5+
:parameters ()
6+
:precondition (f13)
7+
:effect (when (f1) (f2))
8+
)
9+
(:action test_DETDUP_2
10+
:parameters ()
11+
:precondition (f13)
12+
:effect (f3)
13+
)
14+
)

tests/test_det.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ def test_09():
112112

113113
assert domain_to_string(domain_det) == domain_expected
114114

115+
def test_10():
116+
"""tests if we have a basic condeff as an outcome"""
117+
domain = parse_domain(TEST_DIRECTORY / "domain_07.pddl")
118+
domain_det = determinize(domain, dom_suffix="")
119+
120+
with open(TEST_DIRECTORY / "domain_07_det.pddl", "r") as file:
121+
domain_expected = file.read()
122+
123+
assert domain_to_string(domain_det) == domain_expected
124+
115125

116126
if __name__ == "__main__":
117127
test_01()
@@ -123,3 +133,4 @@ def test_09():
123133
test_07()
124134
test_08()
125135
test_09()
136+
test_10()

0 commit comments

Comments
 (0)