Skip to content

Commit

Permalink
Boolean expressions of objective prerequisites
Browse files Browse the repository at this point in the history
Closes #795
  • Loading branch information
kostmo committed Jan 21, 2023
1 parent adab34a commit 5ea849f
Show file tree
Hide file tree
Showing 55 changed files with 1,955 additions and 111 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ stan.html

.swarm_history

*.orig
*.aux
*.log
docs/ott/*.tex
Expand Down
8 changes: 8 additions & 0 deletions data/scenarios/Challenges/Ranching/gated-paddock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ objectives:
} {
return false;
}
id: enclose_sheep
- goal:
- |
Safe! Your sheep are now hungry.
Expand Down Expand Up @@ -311,6 +312,10 @@ objectives:
end;
anySheep (has "clover") 3;
id: feed_sheep
prerequisite:
logic:
id: enclose_sheep
- goal:
- |
Yum! Contented, well-fed sheep may drop wool.
Expand All @@ -323,6 +328,9 @@ objectives:
as base {
has "sweater";
};
prerequisite:
logic:
id: feed_sheep
robots:
- name: base
dir: [0, 1]
Expand Down
4 changes: 4 additions & 0 deletions data/scenarios/Challenges/bucket-brigade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ objectives:
You'll have to make do...
condition: |
as base {has "coal lump"}
id: deliver_coal_lump
- goal:
- Your base got some coal!
- Now fashion more of it into a "coal briquette", and place it
Expand All @@ -75,6 +76,9 @@ objectives:
condition: |
hauler <- robotnamed "hauler";
as hauler {has "coal briquette"}
prerequisite:
logic:
id: deliver_coal_lump
solution: |
run "scenarios/Challenges/_bucket-brigade/brigade.sw"
entities:
Expand Down
1 change: 1 addition & 0 deletions data/scenarios/Testing/00-ORDER.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
684-swap.yaml
699-movement-fail
858-inventory
795-prerequisite
710-multi-robot.yaml
920-meet.yaml
955-heading.yaml
Expand Down
4 changes: 4 additions & 0 deletions data/scenarios/Testing/378-objectives.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ objectives:
n <- as base {count "tree"};
return (n >= 3)
} { return false }
id: get_trees
- goal:
- Nice job. Now, build a harvester.
condition: |
try { as base {has "harvester"} } {return false}
prerequisite:
logic:
id: get_trees
solution: |
build {turn right; move; move; grab; move; grab; move; grab; turn back; move; move; move; move};
wait 16;
Expand Down
4 changes: 4 additions & 0 deletions data/scenarios/Testing/795-prerequisite/00-ORDER.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
795-prerequisite-or.yaml
795-prerequisite-and.yaml
795-prerequisite-mutually-exclusive.yaml
795-prerequisite-cycle-with-not.yaml
50 changes: 50 additions & 0 deletions data/scenarios/Testing/795-prerequisite/795-prerequisite-and.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: 1
name: |
Prerequisite objectives: AND
description: |
Complete an objective with a prerequisite of either of two other objectives.
objectives:
- goal:
- Achieve both of two other objectives
condition: |
return true;
prerequisite:
previewable: true
logic:
and:
- id: have_furnace
- id: have_gear
- goal:
- Make a "furnace".
condition: |
as base {has "furnace"};
id: have_furnace
optional: true
- goal:
- Make a "wooden gear".
condition: |
as base {has "wooden gear"};
id: have_gear
optional: true
solution: |
make "furnace";
make "wooden gear";
robots:
- name: base
display:
char: 'Ω'
attr: robot
dir: [0, 1]
devices:
- workbench
- grabber
inventory:
- [2, board]
- [5, rock]
world:
default: [blank]
palette:
'x': [grass, null, base]
upperleft: [0, 0]
map: |
x
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: 1
name: |
Prerequisite objectives: non-dependency cycle due to the NOT
description: |
This should NOT be rejected by the parser.
The two objectives do reference each other,
but the NOT is a distinct reference from the non-negated goal.
objectives:
- goal:
- Make a "furnace".
condition: |
as base {has "furnace"};
id: have_furnace
prerequisite:
logic:
not:
id: have_gear
- goal:
- Make a "wooden gear".
condition: |
as base {has "wooden gear"};
id: have_gear
prerequisite:
logic:
id: have_furnace
solution: |
make "wooden gear";
make "furnace";
robots:
- name: base
display:
char: 'Ω'
attr: robot
dir: [0, 1]
devices:
- workbench
inventory:
- [2, board]
- [5, rock]
world:
default: [blank]
palette:
'x': [grass, null, base]
upperleft: [0, 0]
map: |
x
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
version: 1
name: |
Prerequisite objectives: OR
description: |
Complete an objective with a prerequisite of either of two other objectives.
objectives:
- goal:
- Achieve one of two other objectives
condition: |
return true;
prerequisite:
previewable: true
logic:
or:
- and:
- id: have_furnace
- not:
id: have_flower
- and:
- id: have_gear
- id: have_flower
- goal:
- Make a "furnace".
condition: |
as base {has "furnace"};
id: have_furnace
optional: true
- goal:
- Make a "wooden gear".
condition: |
as base {has "wooden gear"};
id: have_gear
optional: true
- goal:
- Possess a "flower".
condition: |
as base {has "flower"};
id: have_flower
optional: true
solution: |
make "furnace"
robots:
- name: base
display:
char: 'Ω'
attr: robot
dir: [0, 1]
devices:
- workbench
- grabber
inventory:
- [2, board]
- [5, rock]
world:
default: [blank]
palette:
'x': [grass, flower, base]
upperleft: [0, 0]
map: |
x
49 changes: 49 additions & 0 deletions data/scenarios/Testing/795-prerequisite/795-prerequisite-or.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: 1
name: |
Prerequisite objectives: OR
description: |
Complete an objective with a prerequisite of either of two other objectives.
objectives:
- goal:
- Achieve one of two other objectives
condition: |
return true;
prerequisite:
previewable: true
logic:
or:
- id: have_furnace
- id: have_gear
- goal:
- Make a "furnace".
condition: |
as base {has "furnace"};
id: have_furnace
optional: true
- goal:
- Make a "wooden gear".
condition: |
as base {has "wooden gear"};
id: have_gear
optional: true
solution: |
make "wooden gear"
robots:
- name: base
display:
char: 'Ω'
attr: robot
dir: [0, 1]
devices:
- workbench
- grabber
inventory:
- [2, board]
- [5, rock]
world:
default: [blank]
palette:
'x': [grass, flower, base]
upperleft: [0, 0]
map: |
x
42 changes: 42 additions & 0 deletions data/scenarios/Testing/_Validation/795-prerequisite-cycle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: 1
name: |
Prerequisite objectives: dependency cycle
description: |
This should be rejected by the parser.
objectives:
- goal:
- Make a "furnace".
condition: |
as base {has "furnace"};
id: have_furnace
prerequisite:
logic:
id: have_gear
- goal:
- Make a "wooden gear".
condition: |
as base {has "wooden gear"};
id: have_gear
prerequisite:
logic:
id: have_furnace
solution: |
make "wooden gear"
robots:
- name: base
display:
char: 'Ω'
attr: robot
dir: [0, 1]
devices:
- workbench
inventory:
- [2, board]
- [5, rock]
world:
default: [blank]
palette:
'x': [grass, null, base]
upperleft: [0, 0]
map: |
x
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: 1
name: |
Prerequisite objectives: Nonexistent reference
description: |
This scenario should be unparseable due to typo "shave_furnace" vs "have_furnace"
objectives:
- goal:
- Achieve one of two other objectives
condition: |
return true;
prerequisite:
logic:
id: shave_furnace
- goal:
- Make a "furnace".
condition: |
as base {has "furnace"};
id: have_furnace
optional: true
solution: |
make "furnace"
robots:
- name: base
display:
char: 'Ω'
attr: robot
dir: [0, 1]
devices:
- workbench
- grabber
inventory:
- [2, board]
- [5, rock]
world:
default: [blank]
palette:
'x': [grass, flower, base]
upperleft: [0, 0]
map: |
x
Loading

0 comments on commit 5ea849f

Please sign in to comment.