-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests for instant entity change detection
- Loading branch information
Showing
7 changed files
with
250 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
version: 1 | ||
name: Using wait with instant | ||
author: Karl Ostmo | ||
description: | | ||
Observe timing of (instant $ wait 1) | ||
interspersed with other commands | ||
creative: false | ||
seed: 0 | ||
objectives: | ||
- goal: | ||
- | | ||
Hare must win by three cells | ||
condition: | | ||
h <- robotnamed "hare"; | ||
hareloc <- as h {whereami}; | ||
t <- robotnamed "tortoise"; | ||
tortoiseloc <- as t {whereami}; | ||
let xDiff = fst hareloc - fst tortoiseloc in | ||
return $ fst hareloc == 0 && xDiff == 3; | ||
solution: | | ||
noop; | ||
robots: | ||
- name: base | ||
dir: [1, 0] | ||
display: | ||
invisible: true | ||
devices: | ||
- hourglass | ||
- logger | ||
- name: tortoise | ||
system: true | ||
display: | ||
invisible: false | ||
attr: green | ||
dir: [1, 0] | ||
program: | | ||
move; move; | ||
move; move; | ||
move; move; | ||
- name: hare | ||
system: true | ||
display: | ||
invisible: false | ||
attr: snow | ||
dir: [1, 0] | ||
program: | | ||
instant ( | ||
move; move; | ||
wait 1; | ||
move; move; | ||
wait 1; | ||
move; move; | ||
); | ||
world: | ||
dsl: | | ||
{blank} | ||
upperleft: [-6, 2] | ||
offset: false | ||
palette: | ||
'.': [grass, erase] | ||
'd': [dirt, erase] | ||
'B': [grass, erase, base] | ||
'T': [grass, erase, tortoise] | ||
'H': [grass, erase, hare] | ||
map: | | ||
B.....d. | ||
T.....d. | ||
H.....d. | ||
......d. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
version: 1 | ||
name: Entity change detection | ||
author: Karl Ostmo | ||
description: | | ||
Ensure that a change to an entity can be observed | ||
by a system robot within a single tick. | ||
In this scenario, the base will first `swap` the | ||
existing `dial (R)`{=entity} with a `dial (G)`{=entity}, | ||
then immediately `swap` again with a `dial (B)`{=entity}. | ||
The system robot should be able to detect the presence | ||
of the `dial (G)`{=entity} before it is `swap`ped a second time. | ||
creative: true | ||
seed: 0 | ||
objectives: | ||
- goal: | ||
- | | ||
Turn the light green | ||
condition: | | ||
as base {has "flower"}; | ||
prerequisite: | ||
not: blue_light | ||
- id: blue_light | ||
teaser: No blue light | ||
optional: true | ||
goal: | ||
- | | ||
Turn the light blue | ||
condition: | | ||
r <- robotnamed "lockbot"; | ||
as r {ishere "dial (B)"}; | ||
robots: | ||
- name: base | ||
dir: [1, 0] | ||
display: | ||
invisible: true | ||
devices: | ||
- hourglass | ||
- fast grabber | ||
- logger | ||
- treads | ||
inventory: | ||
- [1, "dial (R)"] | ||
- [1, "dial (G)"] | ||
- [1, "dial (B)"] | ||
- name: lockbot | ||
system: true | ||
display: | ||
invisible: true | ||
dir: [1, 0] | ||
program: | | ||
run "scenarios/Testing/_1598-detect-entity-change/setup.sw" | ||
inventory: | ||
- [1, flower] | ||
solution: | | ||
wait 2; | ||
move; | ||
move; | ||
swap "dial (G)"; | ||
//wait 0; | ||
swap "dial (B)"; | ||
entities: | ||
- name: "dial (R)" | ||
display: | ||
char: '•' | ||
attr: red | ||
description: | ||
- A red dial | ||
properties: [known, pickable] | ||
- name: "dial (G)" | ||
display: | ||
char: '•' | ||
attr: green | ||
description: | ||
- A green dial | ||
properties: [known, pickable] | ||
- name: "dial (B)" | ||
display: | ||
char: '•' | ||
attr: blue | ||
description: | ||
- A blue dial | ||
properties: [known, pickable] | ||
world: | ||
dsl: | | ||
{blank} | ||
upperleft: [-1, -1] | ||
offset: false | ||
palette: | ||
'.': [grass, erase] | ||
'B': [grass, erase, base] | ||
'c': [grass, dial (R), lockbot] | ||
map: | | ||
B.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
version: 1 | ||
name: Watch and Wait with Instant | ||
author: Karl Ostmo | ||
description: | | ||
Ensure that the `watch` command does | ||
not introduce a tick delay. | ||
creative: false | ||
seed: 0 | ||
objectives: | ||
- teaser: Has item | ||
goal: | ||
- | | ||
Observe item | ||
condition: | | ||
r <- robotnamed "watchbot"; | ||
as r {ishere "rock"}; | ||
//as r {return false}; | ||
robots: | ||
- name: base | ||
dir: [1, 0] | ||
devices: | ||
- hourglass | ||
- fast grabber | ||
- logger | ||
- treads | ||
inventory: | ||
- [1, flower] | ||
- [1, tree] | ||
- [1, rock] | ||
- name: watchbot | ||
system: true | ||
display: | ||
invisible: false | ||
dir: [1, 0] | ||
program: | | ||
def watchAndWait = | ||
watch down; | ||
wait 1000; | ||
watchAndWait; | ||
end; | ||
instant watchAndWait; | ||
inventory: | ||
- [1, flower] | ||
solution: | | ||
move; move; | ||
swap "flower"; | ||
swap "tree"; | ||
swap "rock"; | ||
known: [gold] | ||
world: | ||
dsl: | | ||
{blank} | ||
upperleft: [-1, -1] | ||
offset: false | ||
palette: | ||
'.': [grass, erase] | ||
'B': [grass, erase, base] | ||
'c': [grass, gold, watchbot] | ||
map: | | ||
B.c |
17 changes: 17 additions & 0 deletions
17
data/scenarios/Testing/_1598-detect-entity-change/setup.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
def doUntilCorrect = | ||
herenow <- ishere "dial (G)"; | ||
if herenow { | ||
give base "flower"; | ||
} { | ||
watch down; | ||
wait 1000; | ||
doUntilCorrect; | ||
} | ||
end; | ||
|
||
def go = | ||
instant $ | ||
doUntilCorrect; | ||
end; | ||
|
||
go; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters