Skip to content

Commit

Permalink
Add PDDL (#6117)
Browse files Browse the repository at this point in the history
* Add PDDL

* Update lib/linguist/languages.yml

Co-authored-by: Colin Seymour <colin@github.com>

* remove large examples

* Add PDDL  to README

Co-authored-by: Colin Seymour <colin@github.com>
  • Loading branch information
celrm and lildude authored Oct 20, 2022
1 parent ea5e192 commit 90bb4c6
Show file tree
Hide file tree
Showing 9 changed files with 346 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,9 @@
[submodule "vendor/grammars/vscode-opa"]
path = vendor/grammars/vscode-opa
url = https://github.com/tsandall/vscode-opa
[submodule "vendor/grammars/vscode-pddl"]
path = vendor/grammars/vscode-pddl
url = https://github.com/jan-dolejsi/vscode-pddl.git
[submodule "vendor/grammars/vscode-plantuml"]
path = vendor/grammars/vscode-plantuml
url = https://github.com/qjebbs/vscode-plantuml
Expand Down
4 changes: 4 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,10 @@ vendor/grammars/vscode-move-syntax:
- source.move
vendor/grammars/vscode-opa:
- source.rego
vendor/grammars/vscode-pddl:
- source.pddl
- source.pddl.happenings
- source.pddl.plan
vendor/grammars/vscode-plantuml:
- markdown.plantuml.codeblock
- source.wsd
Expand Down
8 changes: 8 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4646,6 +4646,14 @@ P4:
tm_scope: source.p4
ace_mode: text
language_id: 348895984
PDDL:
type: programming
color: "#0d00ff"
extensions:
- ".pddl"
tm_scope: source.pddl
ace_mode: text
language_id: 736235603
PEG.js:
type: programming
color: "#234d6b"
Expand Down
100 changes: 100 additions & 0 deletions samples/PDDL/domain_testproblem.pddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
(define (domain search-and-rescure-scenario)

(:requirements :strips :typing :fluents :disjunctive-preconditions :durative-actions)

(:types drone package location dronezones)

(:constants Area1 Area2 Area3 Area4 - location)

(:functions
(total-cost)
)

(:predicates
(drone-empty ?d - drone)
(holding ?d - drone ?p - package)
(at-drone ?d - drone ?l - location)
(at-package ?p - package ?l - location)
(drone-ground ?d - drone)
(drone-fly ?d - drone)
(location-available ?l - location)
(location-available-drone ?d - drone ?l -location)

)

(:durative-action TAKEOFF
:parameters (?d - drone ?l - location)
:duration ( = ?duration 5)
:condition (and (at start (drone-ground ?d))
(at start(location-available-drone ?d ?l))
(over all(at-drone ?d ?l))
(at start(at-drone ?d ?l))
)
:effect (and (at start(not (drone-ground ?d)))
(at end(drone-fly ?d))
(at start(not (location-available ? l)))
(at start(not(location-available-drone ?d ?l)))
(at start(increase (total-cost) 10))
)
)

(:durative-action LAND
:parameters (?d - drone ?l - location)
:duration ( = ?duration 5)
:condition (and (at start(drone-fly ?d))
(at start(location-available-drone ?d ?l))
(over all(at-drone ?d ?l))
(at start(at-drone ?d ?l))
)
:effect (and (at end(drone-ground ?d))
(at start(not (drone-fly ?d)))
(at start(increase (total-cost) 10))
)

)


(:durative-action LOAD
:parameters (?d - drone ?p - package ?l - location)
:duration (= ?duration 5)
:condition (and (over all(at-drone ?d ?l))
(at start(drone-empty ?d))
(at start(at-package ?p ?l))
(over all(drone-ground ?d)))
:effect (and (at end(holding ?d ?p))
(at start(not (drone-empty ?d)))
(at start(not (location-available ? l)))
(at start(not (at-package ?p ?l)))
(at start(increase (total-cost) 10))
)
)

(:durative-action UNLOAD
:parameters (?d - drone ?p - package ?l - location)
:duration (= ?duration 5)
:condition (and (over all(at-drone ?d ?l))
(at start(holding ?d ?p))
(over all(drone-ground ?d)))
:effect (and (at start(not (holding ?d ?p)))
(at end(drone-empty ?d))
(at end(at-package ?p ?l))
(at start(increase (total-cost) 10))
)
)

(:durative-action MOVE
:parameters (?d - drone ?from ?to - location)
:duration (= ?duration 5)
:condition (and (at start(at-drone ?d ?from))
(over all(drone-fly ?d))
(at start(location-available ?to))
)
:effect (and (at start(not(at-drone ?d ?from)))
(at end(at-drone ?d ?to))
(at start(not (location-available ?to)))
(at start(location-available ?from))
(at end(location-available-drone ?d ?to))
(at start(increase (total-cost) 10))
)
)
)
119 changes: 119 additions & 0 deletions samples/PDDL/pathfinding.pddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
;;Domain for cleaning floor tiles
;; A domain file for CMP2020M assignment 2018/2019
;;Myles Leslie 15614035

;; Define the name for this domain (needs to match the domain definition
;; in the problem files)

(define (domain floor-tile)

;; We only require some typing to make this plan faster. We can do without!
(:requirements :typing)

;; We have two types: robots and the tiles, both are objects
(:types robot tile - object)

;; define all the predicates as they are used in the probem files
(:predicates

;; described what tile a robot is at
(robot-at ?r - robot ?x - tile)

;; indicates that tile ?x is above tile ?y
(up ?x - tile ?y - tile)

;; indicates that tile ?x is below tile ?y
(down ?x - tile ?y - tile)

;; indicates that tile ?x is right of tile ?y
(right ?x - tile ?y - tile)

;; indicates that tile ?x is left of tile ?y
(left ?x - tile ?y - tile)

;; indicates that a tile is clear (robot can move there)
(clear ?x - tile)

;; indicates that a tile is cleaned
(cleaned ?x - tile)
)

;; ACTIONS that need to be defined:
;; defining actions - if tile is cleaned below the robot
(:action clean-down

;; find what tile the robot is at and the where the tile it's going to is
:parameters (?r - robot ?x - tile ?y - tile)

;; find if the tile is below the robot and if it's cleaned
:precondition (and( down ?y ?x)(robot-at ?r ?x) (not(cleaned ?y)))

;; if not cleaned then clean
:effect (and(cleaned ?y))
)

(:action clean-up

;; find what tile the robot is at and the where the tile it's going to is
:parameters (?r - robot ?x - tile ?y - tile)

;; find if the tile is above the robot and if it's cleaned
:precondition (and ( up ?y ?x) (robot-at ?r ?x) (not(cleaned ?y)))

;; if not cleaned then clean
:effect (and(cleaned ?y))
)

;; all further actions are the same except the direction the robot is going
;;when there is a tile below
(:action down

;; find what tile the robot is at and the where the tile it's going to is
:parameters (?r - robot ?x - tile ?y - tile)

;; find if the tile is below the robot, checks if it's clear and if it's cleaned or not
:precondition (and (down ?y ?x )(robot-at ?r ?x ) (clear ?y )(not(cleaned?y)))

;; robot moves to tile if it's clear and doesn't if it isn't clear.
:effect (and (robot-at ?r ?y) (not(robot-at ?r ?x)) (not (clear ?y)) (clear ?x))
)

;;when there is a tile above the robot
(:action up

;; find what tile the robot is at and the where the tile it's going to is
:parameters (?r - robot ?x - tile ?y - tile)

;;find if the tile is above the robot, checks if it's clear and if it's cleaned or not
:precondition (and (up ?y ?x )(robot-at ?r ?x ) (clear ?y )(not(cleaned?y)))

;;robot moves to tile if it's clear and doesn't if it isn't clear.
:effect (and (robot-at ?r ?y) (not(robot-at ?r ?x)) (not (clear ?y)) (clear ?x))
)

;;when there is a tile to the left
(:action left

;; find what tile the robot is at and the where the tile it's going to is
:parameters (?r - robot ?x - tile ?y - tile)

;;find if the tile is to the left of the robot, checks if it's clear and if it's cleaned or not
:precondition (and (left ?y ?x )(robot-at ?r ?x ) (clear ?y )(not(cleaned?y)))

;;robot moves to tile if it's clear and doesn't if it isn't clear.
:effect (and (robot-at ?r ?y) (not(robot-at ?r ?x)) (not (clear ?y)) (clear ?x))
)

;;when there is a tile to the right
(:action right

;; find what tile the robot is at and the where the tile it's going to is
:parameters (?r - robot ?x - tile ?y - tile)

;;find if the tile is to the right of the robot, checks if it's clear and if it's cleaned or not
:precondition (and (right ?y ?x )(robot-at ?r ?x ) (clear ?y )(not(cleaned?y)))

;;robot moves to tile if it's clear and doesn't if it isn't clear.
:effect (and (robot-at ?r ?y) (not(robot-at ?r ?x)) (not (clear ?y)) (clear ?x))
)
)
79 changes: 79 additions & 0 deletions samples/PDDL/problem_4d_5p.pddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
(define (problem search-and-rescure-scenario_task)
(:domain search-and-rescure-scenario)
(:objects
drone1 drone2 drone3 drone4 - drone
RZ1 RZ2 RZ3 RZ4 - location
water1 water2 food1 food2 medicine1 - package
)
(:init
(at-drone drone1 Area1)
(at-drone drone2 Area2)
(at-drone drone3 Area3)
(at-drone drone4 Area4)

(at-package water1 Area1)
(at-package water2 Area1)
(at-package food1 Area2)
(at-package food2 Area3)
(at-package medicine1 Area4)

(drone-empty drone1)
(drone-empty drone2)
(drone-empty drone3)
(drone-empty drone4)

(drone-ground drone1)
(drone-ground drone2)
(drone-ground drone3)
(drone-ground drone4)

(location-available-drone drone1 Area1)
(location-available-drone drone1 Area2)
(location-available-drone drone1 Area3)
(location-available-drone drone1 Area4)

(location-available-drone drone2 Area1)
(location-available-drone drone2 Area2)
(location-available-drone drone2 Area3)
(location-available-drone drone2 Area4)

(location-available-drone drone3 Area1)
(location-available-drone drone3 Area2)
(location-available-drone drone3 Area3)
(location-available-drone drone3 Area4)

(location-available-drone drone4 Area1)
(location-available-drone drone4 Area2)
(location-available-drone drone4 Area3)
(location-available-drone drone4 Area4)

(location-available Area1)
(location-available Area2)
(location-available Area3)
(location-available Area4)
(location-available RZ1)
(location-available RZ2)
(location-available RZ3)
(location-available RZ4)

(= (total-cost) 0)
)
(:goal (and
(at-package water1 RZ1)
(at-package water2 RZ3)
(at-package medicine1 RZ2)
(at-package food2 RZ2)
(at-package food1 RZ4)
(at-drone drone1 Area1)
(at-drone drone2 Area2)
(drone-ground drone1)
(drone-ground drone2)
(at-drone drone3 Area3)
(at-drone drone4 Area4)
(drone-ground drone3)
(drone-ground drone4)
))

(:metric minimize (total-cost))

)
1 change: 1 addition & 0 deletions vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
- **Ox:** [andreashetland/sublime-text-ox](https://github.com/andreashetland/sublime-text-ox)
- **Oz:** [eregon/oz-tmbundle](https://github.com/eregon/oz-tmbundle)
- **P4:** [TakeshiTseng/atom-language-p4](https://github.com/TakeshiTseng/atom-language-p4)
- **PDDL:** [jan-dolejsi/vscode-pddl](https://github.com/jan-dolejsi/vscode-pddl)
- **PEG.js:** [Alhadis/language-grammars](https://github.com/Alhadis/language-grammars)
- **PHP:** [tree-sitter/tree-sitter-php](https://github.com/tree-sitter/tree-sitter-php) 🐌
- **PLpgSQL:** [textmate/sql.tmbundle](https://github.com/textmate/sql.tmbundle)
Expand Down
1 change: 1 addition & 0 deletions vendor/grammars/vscode-pddl
Submodule vscode-pddl added at 24a073
31 changes: 31 additions & 0 deletions vendor/licenses/git_submodule/vscode-pddl.dep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: vscode-pddl
version: 24a0736f1f247a986593c923ebd4235125d157d7
type: git_submodule
homepage: https://github.com/jan-dolejsi/vscode-pddl.git
license: mit
licenses:
- sources: LICENSE
text: |
MIT License
Copyright (c) 2017 jan-dolejsi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
notices: []

0 comments on commit 90bb4c6

Please sign in to comment.