diff --git a/data/domains/keygrid/ground.pddl b/data/domains/keygrid/ground.pddl index ec7347b..71a0c6c 100644 --- a/data/domains/keygrid/ground.pddl +++ b/data/domains/keygrid/ground.pddl @@ -1,55 +1,55 @@ -(define (domain keygrid) - (:requirements :strips :typing) - - - ;; ADDED TO THE ORIGINAL PDDL - (:types place key shape) - ;; ADDED TO THE ORIGINAL PDDL END - - (:predicates - (conn ?x ?y - place) - (key-shape ?k - key ?s - shape) - (lock-shape ?x - place ?s - shape) - (at ?r - key ?x - place) - (at-robot ?x - place) - (locked ?x - place) - (holding ?k - key) - (open ?x - place) - (arm-empty) - ) - - (:action unlock - :parameters (?curpos ?lockpos - place ?key - key ?shape - shape) - :precondition (and - (conn ?curpos ?lockpos) - (key-shape ?key ?shape) - (lock-shape ?lockpos ?shape) - (at-robot ?curpos) - (locked ?lockpos) - (holding ?key)) - :effect (and (open ?lockpos) (not (locked ?lockpos)))) - - (:action move - :parameters (?curpos ?nextpos - place) - :precondition (and (at-robot ?curpos) - (conn ?curpos ?nextpos) (open ?nextpos)) - :effect (and (at-robot ?nextpos) (not (at-robot ?curpos)))) - - (:action pickup - :parameters (?curpos - place ?key - key) - :precondition (and (at-robot ?curpos) - (at ?key ?curpos) (arm-empty )) - :effect (and (holding ?key) (not (at ?key ?curpos)) (not (arm-empty )))) - - (:action pickup-and-loose - :parameters (?curpos - place ?newkey - key ?oldkey - key) - :precondition (and (at-robot ?curpos) (holding ?oldkey) - (at ?newkey ?curpos)) - :effect (and (holding ?newkey) (at ?oldkey ?curpos) - (not (holding ?oldkey)) (not (at ?newkey ?curpos)))) - - (:action putdown - :parameters (?curpos - place ?key - key) - :precondition (and (at-robot ?curpos) (holding ?key)) - :effect (and (arm-empty) (at ?key ?curpos) (not (holding ?key)))) - ) +(define (domain keygrid) + (:requirements :strips :typing) + + + ;; ADDED TO THE ORIGINAL PDDL + (:types place key shape) + ;; ADDED TO THE ORIGINAL PDDL END + + (:predicates + (conn ?x ?y - place) + (key-shape ?k - key ?s - shape) + (lock-shape ?x - place ?s - shape) + (at ?r - key ?x - place) + (at-robot ?x - place) + (locked ?x - place) + (holding ?k - key) + (open ?x - place) + (arm-empty) + ) + + (:action unlock + :parameters (?curpos ?lockpos - place ?key - key ?shape - shape) + :precondition (and + (conn ?curpos ?lockpos) + (key-shape ?key ?shape) + (lock-shape ?lockpos ?shape) + (at-robot ?curpos) + (locked ?lockpos) + (holding ?key)) + :effect (and (open ?lockpos) (not (locked ?lockpos)))) + + (:action move + :parameters (?curpos ?nextpos - place) + :precondition (and (at-robot ?curpos) + (conn ?curpos ?nextpos) (open ?nextpos)) + :effect (and (at-robot ?nextpos) (not (at-robot ?curpos)))) + + (:action pickup + :parameters (?curpos - place ?key - key) + :precondition (and (at-robot ?curpos) + (at ?key ?curpos) (arm-empty )) + :effect (and (holding ?key) (not (at ?key ?curpos)) (not (arm-empty )))) + + (:action pickup-and-loose + :parameters (?curpos - place ?newkey - key ?oldkey - key) + :precondition (and (at-robot ?curpos) (holding ?oldkey) + (at ?newkey ?curpos)) + :effect (and (holding ?newkey) (at ?oldkey ?curpos) + (not (holding ?oldkey)) (not (at ?newkey ?curpos)))) + + (:action putdown + :parameters (?curpos - place ?key - key) + :precondition (and (at-robot ?curpos) (holding ?key)) + :effect (and (arm-empty) (at ?key ?curpos) (not (holding ?key)))) + ) diff --git a/data/domains/keygrid/nl.json b/data/domains/keygrid/nl.json index 03605dd..b493a78 100644 --- a/data/domains/keygrid/nl.json +++ b/data/domains/keygrid/nl.json @@ -1,62 +1,62 @@ -{ - "overall": { - "first": "The Grid domain models a robot navigating between connected locations while collecting keys to unlock locked areas.", - "detailed-first": "This domain consists of a finite set of interconnected places. The robot can move between places if they are connected, pick up keys, and unlock locked locations whose locks match the shape of the key it carries. The robot starts at one location and must reach a goal location, possibly requiring it to collect and use keys along the way to unlock passages." - }, - "predicates": { - "at-robot": { - "first": "The robot is at a specific place.", - "detailed-first": "Indicates the robot’s current position within the grid. At any time, the robot can be located at exactly one place." - }, - "at": { - "first": "A key is at a specific place.", - "detailed-first": "Represents that a key is lying at a certain location within the grid. The robot can move to this place to pick up the key." - }, - "conn": { - "first": "Two places are connected.", - "detailed-first": "Defines a bidirectional connection between two places, meaning the robot can move directly between them if no lock blocks the way." - }, - "locked": { - "first": "A place is locked.", - "detailed-first": "Marks a place as locked, preventing the robot from entering until it is unlocked using a matching key." - }, - "open": { - "first": "A place is open.", - "detailed-first": "Indicates that the place is unlocked and accessible for the robot to enter or move through." - }, - "key-shape": { - "first": "A key has a particular shape.", - "detailed-first": "Each key is associated with a shape that determines which locks it can open. Only a key whose shape matches a lock’s shape can unlock that place." - }, - "lock-shape": { - "first": "A place’s lock has a particular shape.", - "detailed-first": "Defines the shape of the lock associated with a specific place. The place can only be unlocked by a key with the same shape." - }, - "holding": { - "first": "The robot is holding a key.", - "detailed-first": "Indicates that the robot is currently carrying a specific key. While holding a key, the robot cannot pick up another one unless it drops the current one." - }, - "arm-empty": { - "first": "The robot is not holding anything.", - "detailed-first": "Shows that the robot’s gripper is empty and can pick up a new key." - } - }, - "actions": { - "move": { - "first": "The robot moves from one place to another connected place.", - "detailed-first": "This action represents basic navigation in the grid. The robot can move between two connected places if the destination is open or has been unlocked. The effect is that the robot changes its position to the new place." - }, - "pickup": { - "first": "The robot picks up a key.", - "detailed-first": "If the robot is at a place containing a key and its arm is empty, it can pick up that key. The effect is that the key is now held by the robot and no longer at the place." - }, - "unlock": { - "first": "The robot unlocks a locked place using a key.", - "detailed-first": "If the robot is holding a key whose shape matches a locked place’s lock-shape, it can perform the unlock action. The effect is that the place becomes open and accessible." - }, - "drop": { - "first": "The robot drops the key it is holding.", - "detailed-first": "This action allows the robot to place a held key down at its current location, freeing its gripper for another key." - } - } -} +{ + "overall": { + "first": "The Grid domain models a robot navigating between connected locations while collecting keys to unlock locked areas.", + "detailed-first": "This domain consists of a finite set of interconnected places. The robot can move between places if they are connected, pick up keys, and unlock locked locations whose locks match the shape of the key it carries. The robot starts at one location and must reach a goal location, possibly requiring it to collect and use keys along the way to unlock passages." + }, + "predicates": { + "at-robot": { + "first": "The robot is at a specific place.", + "detailed-first": "Indicates the robot’s current position within the grid. At any time, the robot can be located at exactly one place." + }, + "at": { + "first": "A key is at a specific place.", + "detailed-first": "Represents that a key is lying at a certain location within the grid. The robot can move to this place to pick up the key." + }, + "conn": { + "first": "Two places are connected.", + "detailed-first": "Defines a bidirectional connection between two places, meaning the robot can move directly between them if no lock blocks the way." + }, + "locked": { + "first": "A place is locked.", + "detailed-first": "Marks a place as locked, preventing the robot from entering until it is unlocked using a matching key." + }, + "open": { + "first": "A place is open.", + "detailed-first": "Indicates that the place is unlocked and accessible for the robot to enter or move through." + }, + "key-shape": { + "first": "A key has a particular shape.", + "detailed-first": "Each key is associated with a shape that determines which locks it can open. Only a key whose shape matches a lock’s shape can unlock that place." + }, + "lock-shape": { + "first": "A place’s lock has a particular shape.", + "detailed-first": "Defines the shape of the lock associated with a specific place. The place can only be unlocked by a key with the same shape." + }, + "holding": { + "first": "The robot is holding a key.", + "detailed-first": "Indicates that the robot is currently carrying a specific key. While holding a key, the robot cannot pick up another one unless it drops the current one." + }, + "arm-empty": { + "first": "The robot is not holding anything.", + "detailed-first": "Shows that the robot’s gripper is empty and can pick up a new key." + } + }, + "actions": { + "move": { + "first": "The robot moves from one place to another connected place.", + "detailed-first": "This action represents basic navigation in the grid. The robot can move between two connected places if the destination is open or has been unlocked. The effect is that the robot changes its position to the new place." + }, + "pickup": { + "first": "The robot picks up a key.", + "detailed-first": "If the robot is at a place containing a key and its arm is empty, it can pick up that key. The effect is that the key is now held by the robot and no longer at the place." + }, + "unlock": { + "first": "The robot unlocks a locked place using a key.", + "detailed-first": "If the robot is holding a key whose shape matches a locked place’s lock-shape, it can perform the unlock action. The effect is that the place becomes open and accessible." + }, + "drop": { + "first": "The robot drops the key it is holding.", + "detailed-first": "This action allows the robot to place a held key down at its current location, freeing its gripper for another key." + } + } +} diff --git a/data/domains/keygrid/problem_example_human.pddl b/data/domains/keygrid/problem_example_human.pddl index 5594c08..4044a03 100644 --- a/data/domains/keygrid/problem_example_human.pddl +++ b/data/domains/keygrid/problem_example_human.pddl @@ -1,34 +1,34 @@ -(define (problem simple-grid-problem) - (:domain keygrid) - - (:objects - place1 place2 - place - key1 - key - square - shape - ) - - (:init - - ;; connectivity - (conn place1 place2) - - ;; shapes - (shape square) - (key-shape key1 square) - (lock-shape place2 square) - - ;; initial states - (at-robot place1) - (at key1 place1) - (locked place2) - (arm-empty) - - ;; by default, place1 is open - (open place1) - - ) - - (:goal - (at-robot place2) - ) +(define (problem simple-grid-problem) + (:domain keygrid) + + (:objects + place1 place2 - place + key1 - key + square - shape + ) + + (:init + + ;; connectivity + (conn place1 place2) + + ;; shapes + (shape square) + (key-shape key1 square) + (lock-shape place2 square) + + ;; initial states + (at-robot place1) + (at key1 place1) + (locked place2) + (arm-empty) + + ;; by default, place1 is open + (open place1) + + ) + + (:goal + (at-robot place2) + ) ) \ No newline at end of file diff --git a/data/domains/pacman-63/ground.pddl b/data/domains/pacman-63/ground.pddl index 35dd9fc..9d8b417 100644 --- a/data/domains/pacman-63/ground.pddl +++ b/data/domains/pacman-63/ground.pddl @@ -5,10 +5,9 @@ (:predicates (has_food ?location - node) (no_food ?location - node) - (is_safe ?location - node) ; complement of is_opponent_ghost + (is_safe ?location - node) ; No ghosts present (is_visited ?location - node) (at ?location - node) - (not_at ?location - node) (connected ?n1 ?n2 - node) ) @@ -16,14 +15,12 @@ :parameters (?start ?end - node) :precondition (and (at ?start) - (not_at ?end) (no_food ?end) (connected ?start ?end) (is_safe ?end) ) :effect (and (at ?end) - (not_at ?start) (is_visited ?end) ) ) @@ -38,7 +35,6 @@ ) :effect (and (at ?end) - (not_at ?start) (no_food ?end) (is_visited ?end) ) diff --git a/data/domains/pacman-63/nl.json b/data/domains/pacman-63/nl.json index 52d01bb..3c94b4e 100644 --- a/data/domains/pacman-63/nl.json +++ b/data/domains/pacman-63/nl.json @@ -23,11 +23,7 @@ }, "at": { "first": "Pacman is currently at a node.", - "detailed-first": "Shows Pacman’s current position in the environment." - }, - "not_at": { - "first": "Pacman is not at this node.", - "detailed-first": "Indicates that Pacman is not currently at the node." + "detailed-first": "Shows Pacman's current position in the environment." }, "connected": { "first": "Two nodes are connected.", diff --git a/nl3pddl/problem_generators/pacman_63.py b/nl3pddl/problem_generators/pacman_63.py index dfd1c54..689f050 100644 --- a/nl3pddl/problem_generators/pacman_63.py +++ b/nl3pddl/problem_generators/pacman_63.py @@ -52,12 +52,10 @@ def generate_pacman_63_problem(n, output_file, seed=None): # Initial state problem += " (:init\n" - # Pacman's position + # Pacman's starting position for node in nodes: if node == start_node: problem += f" (at {node})\n" - else: - problem += f" (not_at {node})\n" # Food distribution for node in nodes: