Skip to content

Commit

Permalink
Add second generator for grid based on MiniGrid Gym environment (#29)
Browse files Browse the repository at this point in the history
Co-authored-by: Jendrik Seipp <jendrik.seipp@liu.se>
  • Loading branch information
bonetblai and jendrikseipp authored Apr 3, 2023
1 parent a131021 commit 2c51b64
Show file tree
Hide file tree
Showing 20 changed files with 514 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ maintenance/maintenance
miconic/miconic
miconic-fulladl/miconic
miconic-simpleadl/miconic
minigrid/log.txt
minigrid/grid_4room2_fpl_s3_seed0_n0.pddl
movie/movie
mprime/mprime
mystery/mystery
Expand Down
6 changes: 6 additions & 0 deletions minigrid/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Without this dummy target, the test target becomes the default target.
build:
echo nothing to build

test:
./mini_grid.py floorplans/4room2.fpl 3
45 changes: 45 additions & 0 deletions minigrid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Mini-Grid

This is an alternative generator for the Grid domain, which was proposed by Drew
McDermott for the AIPS-1998 competition. You can find the original generator
under "grid".

The "minigrid" generator is inspired by the Gym environment called MiniGrid that is
heavily used in RL/DRL. The generator, that is guaranteed to generate solvable
and interesting instances, is from Blai Bonet (https://github.com/bonetblai/mini-grid).

Random instances are generated used given floorplans which already contain "walls"
that create rooms, and locked cells that serve as doors between rooms. On such
floorplans, shapes and keys are randomly assigned and placed around, together
with initial and goal position for the robot. The goal is always for the robot
to reach a designated cell.

Different floorplans are provided but new floorplans can be used in creative ways,
not necessarily rectangular shapes. The original repository contains example
problems generated from the given floorplans together with solutions computed
with pyperplan.

The options for the generator are:

```
usage: mini_grid.py [-h] [--seed SEED] [--debug_level DEBUG_LEVEL] [--num_instances NUM_INSTANCES] [--results RESULTS] [--floorplans_path FLOORPLANS_PATH] floorplan nshapes
positional arguments:
floorplan Filename for floorplan
nshapes Number of shapes for locks (0 means choose it randomly)
options:
-h, --help show this help message and exit
--seed SEED Seed for random generator (default=0)
--debug_level DEBUG_LEVEL
Set debug level (default=0)
--num_instances NUM_INSTANCES
Number of instances to generate (default=1)
paths:
--results RESULTS Path to results folders (default='')
--floorplans_path FLOORPLANS_PATH
Path to floorplans (default='')
```


55 changes: 55 additions & 0 deletions minigrid/domain.pddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
(define (domain grid)
(:requirements :strips)
(:predicates (conn ?x ?y)
(key-shape ?k ?s)
(lock-shape ?x ?s)
(at ?r ?x )
(at-robot ?x)
(place ?p)
(key ?k)
(shape ?s)
(locked ?x)
(holding ?k)
(open ?x)
(arm-empty ))



(:action unlock
:parameters (?curpos ?lockpos ?key ?shape)
:precondition (and (place ?curpos) (place ?lockpos) (key ?key) (shape ?shape)
(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)
:precondition (and (place ?curpos) (place ?nextpos)
(at-robot ?curpos) (conn ?curpos ?nextpos) (open ?nextpos))
:effect (and (at-robot ?nextpos) (not (at-robot ?curpos))))

(:action pickup
:parameters (?curpos ?key)
:precondition (and (place ?curpos) (key ?key)
(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 ?newkey ?oldkey)
:precondition (and (place ?curpos) (key ?newkey) (key ?oldkey)
(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 ?key)
:precondition (and (place ?curpos) (key ?key)
(at-robot ?curpos) (holding ?key))
:effect (and (arm-empty ) (at ?key ?curpos) (not (holding ?key)))))



2 changes: 2 additions & 0 deletions minigrid/floorplans/2Hroom2.fpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
..w..
..L..
3 changes: 3 additions & 0 deletions minigrid/floorplans/2Hroom3.fpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
...w...
...L...
...w...
5 changes: 5 additions & 0 deletions minigrid/floorplans/2Vroom2.fpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
..
..
Lw
..
..
7 changes: 7 additions & 0 deletions minigrid/floorplans/2Vroom3.fpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
...
...
...
Lww
...
...
...
2 changes: 2 additions & 0 deletions minigrid/floorplans/3Hroom2.fpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
..w..L..
..L..w..
3 changes: 3 additions & 0 deletions minigrid/floorplans/3Hroom3.fpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
...w...L...
...L...w...
...w...w...
8 changes: 8 additions & 0 deletions minigrid/floorplans/3Vroom2.fpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
..
..
Lw
..
..
wL
..
..
11 changes: 11 additions & 0 deletions minigrid/floorplans/3Vroom3.fpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
...
...
...
Lww
...
...
...
wwL
...
...
...
5 changes: 5 additions & 0 deletions minigrid/floorplans/4room2.fpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
..L..
..w..
LwwLw
..w..
..w..
7 changes: 7 additions & 0 deletions minigrid/floorplans/4room3.fpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
...L...
...w...
...w...
wLwwLww
...w...
...w...
...w...
8 changes: 8 additions & 0 deletions minigrid/floorplans/9room2.fpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
..L..w..
..w..L..
LwwwwwwL
..L..w..
..w..L..
wLwwwwww
..w..L..
..L..w..
11 changes: 11 additions & 0 deletions minigrid/floorplans/9room3.fpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
...L...w...
...w...L...
...w...w...
wLwwwwwwLww
...L...w...
...w...L...
...w...w...
wwLwwwwwwww
...w...L...
...w...w...
...L...w...
2 changes: 2 additions & 0 deletions minigrid/floorplans/room2.fpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
..
..
4 changes: 4 additions & 0 deletions minigrid/floorplans/room4.fpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
....
....
....
....
6 changes: 6 additions & 0 deletions minigrid/floorplans/room6.fpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
......
......
......
......
......
......
Loading

0 comments on commit 2c51b64

Please sign in to comment.