-
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
8 changed files
with
228 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
basic-subworld.yaml | ||
subworld-shared-structures.yaml | ||
subworld-robots.yaml | ||
subworld-mapped-robots.yaml | ||
subworld-located-robots.yaml |
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"; | ||
|
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
115 changes: 115 additions & 0 deletions
115
data/scenarios/Testing/144-subworlds/subworld-mapped-robots.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: Subworld robots (map placement) | ||
description: | | ||
Demonstrate that system robots can be placed in any subworld. | ||
Also demonstrates tiebreaking logic for robot numbering based | ||
on subworld. | ||
objectives: | ||
- goal: | ||
- | | ||
`give` the "bitcoin" to the robot in the "root" world. | ||
- | | ||
First obtain it from the robot living underground. | ||
condition: | | ||
j <- robotnumbered 1; | ||
as j {has "bitcoin"} | ||
solution: | | ||
run "scenarios/Testing/144-subworlds/_subworld-mapped-robots/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 | ||
- antenna | ||
- 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: false | ||
program: | | ||
run "scenarios/Testing/144-subworlds/_subworld-mapped-robots/judges.sw"; | ||
known: [boulder] | ||
subworlds: | ||
- name: underground | ||
default: [blank] | ||
palette: | ||
'.': [dirt] | ||
'b': [dirt, boulder] | ||
't': [grass, null, judge] | ||
'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.t....P. | ||
b..b..b..b | ||
world: | ||
default: [blank] | ||
palette: | ||
'.': [grass] | ||
'B': [grass, null, base] | ||
't': [grass, 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.B..t.P. | ||
.......... |
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