-
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.
Closes #144. This builds upon portals support (#1356) # Demo scripts/play.sh --scenario data/scenarios/Testing/144-subworlds/subworld-mapped-robots.yaml --autoplay --speed 2 [![asciicast](https://asciinema.org/a/vC13dW8M1S8t2b1J4XkW80U1q.svg)](https://asciinema.org/a/vC13dW8M1S8t2b1J4XkW80U1q) # Future work * Augment portal definitions with an optional "relative orientation" attribute, that can turn the player around when passing through the portal (#1379) * Specify whether portal performs instant transportation or whether `move down` is required (#1368)
- Loading branch information
Showing
48 changed files
with
1,824 additions
and
315 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 |
---|---|---|
|
@@ -38,3 +38,4 @@ | |
1295-density-command.yaml | ||
1138-structures | ||
1356-portals | ||
144-subworlds |
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,5 @@ | ||
basic-subworld.yaml | ||
subworld-shared-structures.yaml | ||
subworld-mapped-robots.yaml | ||
subworld-located-robots.yaml | ||
spatial-consistency-enforcement.yaml |
7 changes: 7 additions & 0 deletions
7
data/scenarios/Testing/144-subworlds/_basic-subworld/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,7 @@ | ||
|
||
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end; | ||
|
||
doN 8 move; | ||
f <- grab; | ||
doN 7 move; | ||
place f; |
10 changes: 10 additions & 0 deletions
10
data/scenarios/Testing/144-subworlds/_subworld-located-robots/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,10 @@ | ||
|
||
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end; | ||
|
||
doN 3 move; | ||
f <- grab; | ||
|
||
doN 5 move; | ||
r <- meet; | ||
case r return $ \j. give j f; | ||
|
52 changes: 52 additions & 0 deletions
52
data/scenarios/Testing/144-subworlds/_subworld-mapped-robots/judges.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,52 @@ | ||
|
||
def getRobotNumber = \n. | ||
r <- robotnumbered n; | ||
if (r == self) { | ||
return n; | ||
} {getRobotNumber $ n + 1}; | ||
end; | ||
|
||
def amLowestRecursive = \targetName. \idx. | ||
r <- robotnumbered idx; | ||
thisName <- as r {whoami}; | ||
if (thisName == targetName) { | ||
return $ r == self; | ||
} {amLowestRecursive targetName $ idx + 1}; | ||
end; | ||
|
||
/** | ||
Iterates through robots by increasing index. | ||
If we encounter a robot, fetched by index, | ||
with the same name as me, but I am not that robot, | ||
then we return false. | ||
*/ | ||
def amFirstOfMyName = | ||
myName <- whoami; | ||
amLowestRecursive myName 0; | ||
end; | ||
|
||
def waitToGiveThing = \thing. | ||
r <- meet; | ||
case r (\_. wait 1; waitToGiveThing thing) $ \b. give b thing; | ||
end; | ||
|
||
def waitToGive = | ||
let thing = "bitcoin" in | ||
create thing; | ||
waitToGiveThing thing; | ||
end; | ||
|
||
def waitToReceive = | ||
noop; | ||
end; | ||
|
||
def go = | ||
myNumber <- getRobotNumber 0; | ||
log $ "My number: " ++ format myNumber; | ||
amFirst <- amFirstOfMyName; | ||
log $ "Am first with this name? " ++ format amFirst; | ||
|
||
if amFirst {waitToReceive} {waitToGive}; | ||
end; | ||
|
||
go; |
8 changes: 8 additions & 0 deletions
8
data/scenarios/Testing/144-subworlds/_subworld-mapped-robots/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,8 @@ | ||
|
||
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end; | ||
|
||
doN 16 move; | ||
|
||
r <- meet; | ||
case r return $ \j. give j "bitcoin"; | ||
|
108 changes: 108 additions & 0 deletions
108
data/scenarios/Testing/144-subworlds/basic-subworld.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,108 @@ | ||
version: 1 | ||
name: Subworlds demo | ||
description: | | ||
Surface and underground with portals. | ||
objectives: | ||
- goal: | ||
- | | ||
`place` the "flower" on the white cell. | ||
condition: | | ||
j <- robotnamed "judge"; | ||
as j {ishere "flower"} | ||
solution: | | ||
run "scenarios/Testing/144-subworlds/_basic-subworld/solution.sw" | ||
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 | ||
dir: [1, 0] | ||
devices: | ||
- ADT calculator | ||
- branch predictor | ||
- comparator | ||
- compass | ||
- dictionary | ||
- GPS receiver | ||
- grabber | ||
- lambda | ||
- lodestone | ||
- logger | ||
- strange loop | ||
- treads | ||
- name: judge | ||
dir: [1, 0] | ||
system: true | ||
display: | ||
char: 'J' | ||
invisible: true | ||
known: [flower, boulder] | ||
subworlds: | ||
- name: underground | ||
default: [blank] | ||
palette: | ||
'.': [dirt] | ||
'f': [dirt, flower] | ||
'b': [dirt, boulder] | ||
'p': | ||
cell: [dirt, telepad exit] | ||
waypoint: | ||
name: portal_out2 | ||
'P': | ||
cell: [dirt, telepad entrance] | ||
waypoint: | ||
name: portal_in2 | ||
portals: | ||
- entrance: portal_in2 | ||
exitInfo: | ||
exit: portal_out1 | ||
subworldName: root | ||
upperleft: [-1, 1] | ||
map: | | ||
b..b..b..b | ||
.p..f...P. | ||
b..b..b..b | ||
world: | ||
name: root | ||
default: [blank] | ||
palette: | ||
'.': [grass] | ||
'B': [grass, null, base] | ||
't': [ice, null, judge] | ||
'p': | ||
cell: [grass, telepad exit] | ||
waypoint: | ||
name: portal_out1 | ||
'P': | ||
cell: [grass, telepad entrance] | ||
waypoint: | ||
name: portal_in1 | ||
upperleft: [-1, 1] | ||
portals: | ||
- entrance: portal_in1 | ||
exitInfo: | ||
exit: portal_out2 | ||
subworldName: underground | ||
map: | | ||
.......... | ||
.p.Bt...P. | ||
.......... |
93 changes: 93 additions & 0 deletions
93
data/scenarios/Testing/144-subworlds/spatial-consistency-enforcement.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,93 @@ | ||
version: 1 | ||
name: Subworld spatial consistency enforcement | ||
description: | | ||
Portals annotated to enforce spatial consistency between subworlds | ||
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 | ||
dir: [1, 0] | ||
devices: | ||
- ADT calculator | ||
- branch predictor | ||
- comparator | ||
- compass | ||
- dictionary | ||
- GPS receiver | ||
- grabber | ||
- lambda | ||
- lodestone | ||
- logger | ||
- strange loop | ||
- treads | ||
known: [boulder] | ||
subworlds: | ||
- name: underground | ||
default: [blank] | ||
palette: | ||
'.': [dirt] | ||
'b': [dirt, boulder] | ||
'p': | ||
cell: [dirt, telepad exit] | ||
waypoint: | ||
name: portal_out2 | ||
'P': | ||
cell: [dirt, telepad entrance] | ||
waypoint: | ||
name: portal_in2 | ||
portals: | ||
- entrance: portal_in2 | ||
exitInfo: | ||
exit: portal_out1 | ||
subworldName: root | ||
consistent: true | ||
upperleft: [-1, 1] | ||
map: | | ||
b..b..b..b | ||
.P......p. | ||
b..b..b..b | ||
world: | ||
name: root | ||
default: [blank] | ||
palette: | ||
'.': [grass] | ||
'B': [grass, null, base] | ||
'p': | ||
cell: [grass, telepad exit] | ||
waypoint: | ||
name: portal_out1 | ||
'P': | ||
cell: [grass, telepad entrance] | ||
waypoint: | ||
name: portal_in1 | ||
upperleft: [-1, 1] | ||
portals: | ||
- entrance: portal_in1 | ||
exitInfo: | ||
exit: portal_out2 | ||
subworldName: underground | ||
consistent: true | ||
map: | | ||
.......... | ||
.p.B....P. | ||
.......... |
Oops, something went wrong.