-
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.
- Loading branch information
Showing
39 changed files
with
1,084 additions
and
127 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
automatic-waypoint-patrol.yaml | ||
portals-and-waypoints.yaml | ||
portals-flip-and-rotate.yaml |
49 changes: 49 additions & 0 deletions
49
data/scenarios/Testing/1356-portals/_automatic-waypoint-patrol/program.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,49 @@ | ||
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end; | ||
def abs = \n. if (n < 0) {-n} {n} end; | ||
|
||
def mapTuple = \f. \t. | ||
(f $ fst t, f $ snd t) | ||
end; | ||
|
||
def sumTuples = \t1. \t2. | ||
(fst t1 + fst t2, snd t1 + snd t2); | ||
end; | ||
|
||
def negateTuple = \t. | ||
mapTuple (\x. -x) t; | ||
end; | ||
|
||
def getRelativeLocation = \absCurrentLoc. \absDestLoc. | ||
let negatedLoc = negateTuple absCurrentLoc in | ||
return $ sumTuples negatedLoc absDestLoc; | ||
end; | ||
|
||
def moveTuple = \tup. | ||
let x = fst tup in | ||
let y = snd tup in | ||
turn $ if (x > 0) {east} {west}; | ||
doN (abs x) move; | ||
turn $ if (y > 0) {north} {south}; | ||
doN (abs y) move; | ||
end; | ||
|
||
def goToLocation = \currentLoc. \absoluteDestination. | ||
relativeDestination <- getRelativeLocation currentLoc absoluteDestination; | ||
moveTuple relativeDestination; | ||
end; | ||
|
||
def visitNextWaypoint = \nextWpIdx. | ||
loc <- whereami; | ||
nextWaypointQuery <- waypoint "wp" nextWpIdx; | ||
goToLocation loc $ snd nextWaypointQuery; | ||
|
||
visitNextWaypoint $ nextWpIdx + 1; | ||
end; | ||
|
||
def go = | ||
waypointQuery <- waypoint "wp" 0; | ||
teleport self $ snd waypointQuery; | ||
visitNextWaypoint 1; | ||
end; | ||
|
||
go; |
61 changes: 61 additions & 0 deletions
61
data/scenarios/Testing/1356-portals/_portals-flip-and-rotate/solution.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,61 @@ | ||
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end; | ||
|
||
def abs = \n. if (n < 0) {-n} {n} end; | ||
|
||
def mapTuple = \f. \t. | ||
(f $ fst t, f $ snd t) | ||
end; | ||
|
||
def sumTuples = \t1. \t2. | ||
(fst t1 + fst t2, snd t1 + snd t2); | ||
end; | ||
|
||
def negateTuple = \t. | ||
mapTuple (\x. -x) t; | ||
end; | ||
|
||
def getRelativeLocation = \absCurrentLoc. \absDestLoc. | ||
let negatedLoc = negateTuple absCurrentLoc in | ||
return $ sumTuples negatedLoc absDestLoc; | ||
end; | ||
|
||
def moveTuple = \tup. | ||
let x = fst tup in | ||
let y = snd tup in | ||
turn $ if (x > 0) {east} {west}; | ||
doN (abs x) move; | ||
turn $ if (y > 0) {north} {south}; | ||
doN (abs y) move; | ||
end; | ||
|
||
def goToLocation = \currentLoc. \absoluteDestination. | ||
relativeDestination <- getRelativeLocation currentLoc absoluteDestination; | ||
moveTuple relativeDestination; | ||
end; | ||
|
||
def goToBottom = | ||
turn south; doN 14 move; | ||
end; | ||
|
||
def go = | ||
goToLocation (0, 0) (3, -2); | ||
goToLocation (0, 0) (12, -2); | ||
goToLocation (0, 0) (18, -5); | ||
goToLocation (0, 0) (23, -3); | ||
|
||
goToBottom; | ||
goToLocation (0, -14) (3, -12); | ||
goToBottom; | ||
goToLocation (0, -14) (9, -9); | ||
goToBottom; | ||
goToLocation (0, -14) (18, -9); | ||
goToBottom; | ||
goToLocation (0, -14) (26, -10); | ||
|
||
turn east; | ||
doN 29 move; | ||
goToBottom; | ||
grab; | ||
end; | ||
|
||
go; |
73 changes: 73 additions & 0 deletions
73
data/scenarios/Testing/1356-portals/automatic-waypoint-patrol.yaml
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,73 @@ | ||
version: 1 | ||
name: Querying waypoints | ||
description: | | ||
Demonstrate patrolling between waypoints | ||
creative: true | ||
robots: | ||
- name: base | ||
loc: [0, 0] | ||
dir: [1, 0] | ||
- name: patroller | ||
loc: [5, -4] | ||
dir: [1, 0] | ||
display: | ||
invisible: false | ||
attr: robot | ||
program: | | ||
run "scenarios/Testing/1356-portals/_automatic-waypoint-patrol/program.sw" | ||
known: [flower, boulder] | ||
world: | ||
upperleft: [-1, 1] | ||
default: [blank] | ||
palette: | ||
'.': [grass] | ||
'*': [stone, flower] | ||
'┌': [stone, upper left corner] | ||
'┐': [stone, upper right corner] | ||
'└': [stone, lower left corner] | ||
'┘': [stone, lower right corner] | ||
'─': [stone, horizontal wall] | ||
'│': [stone, vertical wall] | ||
structures: | ||
- name: bigbox | ||
structure: | ||
palette: | ||
'.': [dirt] | ||
'@': [dirt, boulder] | ||
'w': | ||
cell: [dirt] | ||
waypoint: | ||
name: wp | ||
map: | | ||
@@@ | ||
@w. | ||
@.@ | ||
placements: | ||
- src: bigbox | ||
offset: [2, -2] | ||
orient: | ||
up: "DNorth" | ||
- src: bigbox | ||
offset: [8, -2] | ||
orient: | ||
up: "DEast" | ||
- src: bigbox | ||
offset: [8, -6] | ||
orient: | ||
up: "DSouth" | ||
- src: bigbox | ||
offset: [2, -6] | ||
orient: | ||
up: "DWest" | ||
map: | | ||
┌───────────┐ | ||
│*..*..*..*.│ | ||
│.*..*..*..*│ | ||
│..*..*..*..│ | ||
│*..*..*..*.│ | ||
│.*..*..*..*│ | ||
│..*..*..*..│ | ||
│*..*..*..*.│ | ||
│.*..*..*..*│ | ||
│..*..*..*..│ | ||
└───────────┘ |
115 changes: 115 additions & 0 deletions
115
data/scenarios/Testing/1356-portals/portals-and-waypoints.yaml
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,115 @@ | ||
version: 1 | ||
name: Waypoints for nested structures | ||
description: | | ||
Demonstrate behavior of waypoints across structure overlays | ||
creative: true | ||
attrs: | ||
- name: portal_in | ||
fg: "#ff9a00" | ||
bg: "#ff5d00" | ||
- name: portal_out | ||
fg: "#00a2ff" | ||
bg: "#0065ff" | ||
entities: | ||
- name: telepad entrance | ||
display: | ||
attr: portal_in | ||
char: "o" | ||
description: | ||
- Portal entrance | ||
properties: [known] | ||
- name: telepad exit | ||
display: | ||
attr: portal_out | ||
char: "o" | ||
description: | ||
- Portal exit | ||
properties: [known] | ||
robots: | ||
- name: base | ||
loc: [0, 4] | ||
dir: [1, 0] | ||
known: [tree, flower, sand, bit (0), bit (1)] | ||
world: | ||
upperleft: [-4, 7] | ||
default: [blank] | ||
palette: | ||
'.': [grass] | ||
'*': [stone, flower] | ||
'P': [grass, telepad entrance] | ||
'p': [grass, telepad exit] | ||
'┌': [stone, upper left corner] | ||
'┐': [stone, upper right corner] | ||
'└': [stone, lower left corner] | ||
'┘': [stone, lower right corner] | ||
'─': [stone, horizontal wall] | ||
'│': [stone, vertical wall] | ||
structures: | ||
- name: bitpair | ||
structure: | ||
palette: | ||
'p': [stone, telepad exit] | ||
'1': [stone, bit (1)] | ||
map: | | ||
1 | ||
p | ||
waypoints: | ||
- name: bitpair_bottom | ||
loc: [0, -1] | ||
- name: minibox | ||
structure: | ||
palette: | ||
'.': [stone] | ||
's': [stone, sand] | ||
'P': [stone, telepad entrance] | ||
placements: | ||
- src: bitpair | ||
offset: [1, 0] | ||
waypoints: | ||
- name: minibox_corner | ||
loc: [0, 0] | ||
map: | | ||
P.s | ||
s.s | ||
- name: bigbox | ||
structure: | ||
palette: | ||
'.': [stone] | ||
'T': [stone, tree] | ||
'w': | ||
cell: [dirt, telepad entrance] | ||
waypoint: | ||
name: bigbox_middle | ||
map: | | ||
TTTTTT | ||
T.TwT. | ||
.T.T.T | ||
TTTTTT | ||
placements: | ||
- src: bigbox | ||
offset: [1, -1] | ||
- src: bigbox | ||
offset: [7, -5] | ||
- src: minibox | ||
offset: [1, -7] | ||
waypoints: | ||
- name: meadow | ||
loc: [12, -1] | ||
portals: | ||
- entrance: bigbox_middle | ||
exitInfo: | ||
exit: bitpair_bottom | ||
- entrance: minibox_corner | ||
exitInfo: | ||
exit: meadow | ||
map: | | ||
┌────────────┐ | ||
│*..*..*..*.p│ | ||
│.*..*..*..*.│ | ||
│..*..*..*..*│ | ||
│*..*..*..*..│ | ||
│.*..*..*..*.│ | ||
│..*..*..*..*│ | ||
│*..*..*..*..│ | ||
│.*..*..*..*.│ | ||
└────────────┘ |
Oops, something went wrong.