mirror of
https://github.com/swarm-game/swarm.git
synced 2024-09-11 14:46:33 +03:00
dim sum restaurant (#1686)
scripts/play.sh -i scenarios/Challenges/dimsum.yaml --autoplay ![Screenshot from 2023-12-13 22-39-53](https://github.com/swarm-game/swarm/assets/261693/d3039776-c819-4b1c-acfe-dbd0265e9cb0)
This commit is contained in:
parent
eaa5551471
commit
53e6f35c0e
@ -1284,12 +1284,12 @@
|
||||
char: R
|
||||
attr: silver
|
||||
description:
|
||||
- Enables robots to use the `watch` command.
|
||||
- Enables robots to use the `watch` and `wait` commands.
|
||||
- |
|
||||
`watch : dir -> cmd unit` will mark an adjacent (in the specified direction) location of interest to monitor for placement or removal of items.
|
||||
A subsequent call to `wait` will be interrupted upon a change to the location.
|
||||
properties: [portable]
|
||||
capabilities: [wakeself]
|
||||
capabilities: [timerel, wakeself]
|
||||
|
||||
- name: comparator
|
||||
display:
|
||||
|
@ -17,6 +17,7 @@ wolf-goat-cabbage.yaml
|
||||
blender.yaml
|
||||
friend.yaml
|
||||
pack-tetrominoes.yaml
|
||||
dimsum.yaml
|
||||
Mazes
|
||||
Ranching
|
||||
Sokoban
|
||||
|
24
data/scenarios/Challenges/_dimsum/cook.sw
Normal file
24
data/scenarios/Challenges/_dimsum/cook.sw
Normal file
@ -0,0 +1,24 @@
|
||||
def modifyCart = \cartType. \device.
|
||||
result <- scan forward;
|
||||
case result return (\item.
|
||||
if (item == cartType) {
|
||||
use device forward;
|
||||
return ();
|
||||
} {
|
||||
return ();
|
||||
};
|
||||
);
|
||||
end;
|
||||
|
||||
def watchSpot =
|
||||
watch forward;
|
||||
wait 1000;
|
||||
modifyCart "empty cart" "spatula";
|
||||
end;
|
||||
|
||||
def go =
|
||||
watchSpot;
|
||||
go;
|
||||
end;
|
||||
|
||||
go;
|
24
data/scenarios/Challenges/_dimsum/patron.sw
Normal file
24
data/scenarios/Challenges/_dimsum/patron.sw
Normal file
@ -0,0 +1,24 @@
|
||||
def modifyCart = \cartType. \device.
|
||||
result <- scan forward;
|
||||
case result return (\item.
|
||||
if (item == cartType) {
|
||||
use device forward;
|
||||
return ();
|
||||
} {
|
||||
return ();
|
||||
};
|
||||
);
|
||||
end;
|
||||
|
||||
def watchSpot =
|
||||
watch forward;
|
||||
wait 1000;
|
||||
modifyCart "full cart" "fork";
|
||||
end;
|
||||
|
||||
def go =
|
||||
watchSpot;
|
||||
go;
|
||||
end;
|
||||
|
||||
go;
|
27
data/scenarios/Challenges/_dimsum/solution.sw
Normal file
27
data/scenarios/Challenges/_dimsum/solution.sw
Normal file
@ -0,0 +1,27 @@
|
||||
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end;
|
||||
|
||||
def moveOne =
|
||||
move;
|
||||
move;
|
||||
turn back;
|
||||
push;
|
||||
turn back;
|
||||
end;
|
||||
|
||||
def oneLap =
|
||||
doN 4 (
|
||||
doN 8 moveOne;
|
||||
turn right;
|
||||
);
|
||||
end;
|
||||
|
||||
def moveCartToDiagonal =
|
||||
doN 16 oneLap;
|
||||
end;
|
||||
|
||||
|
||||
def go =
|
||||
doN 4 moveCartToDiagonal;
|
||||
end;
|
||||
|
||||
go;
|
162
data/scenarios/Challenges/dimsum.yaml
Normal file
162
data/scenarios/Challenges/dimsum.yaml
Normal file
@ -0,0 +1,162 @@
|
||||
version: 1
|
||||
name: Dim sum
|
||||
creative: false
|
||||
description: Serve restaurant patrons with the dim sum cart.
|
||||
objectives:
|
||||
- goal:
|
||||
- It is the grand opening of Sigma (Σ), the hot new
|
||||
dim sum restaurant in town.
|
||||
You are the solitary wait staff.
|
||||
- It seems that the manager went a bit overboard on furniture;
|
||||
there are dozens of `table`{=entity}s,
|
||||
but hardly any room to walk!
|
||||
- Serve the blue patron with a `full cart`{=entity} (f) of food, twice.
|
||||
- The `empty cart`{=entity} (e) must be `push`ed to the
|
||||
northwest corner for the cook to load it with food.
|
||||
condition: |
|
||||
p <- robotnamed "patron";
|
||||
as p {
|
||||
foodCount <- count "food";
|
||||
return $ foodCount >= 2;
|
||||
}
|
||||
solution: |
|
||||
run "scenarios/Challenges/_dimsum/solution.sw"
|
||||
robots:
|
||||
- name: base
|
||||
dir: [1, 0]
|
||||
devices:
|
||||
- branch predictor
|
||||
- ADT calculator
|
||||
- compass
|
||||
- comparator
|
||||
- dictionary
|
||||
- grabber
|
||||
- lambda
|
||||
- logger
|
||||
- net
|
||||
- scanner
|
||||
- strange loop
|
||||
- treads
|
||||
- dozer blade
|
||||
- name: cook
|
||||
dir: [0, -1]
|
||||
system: false
|
||||
display:
|
||||
invisible: false
|
||||
attr: red
|
||||
devices:
|
||||
- ADT calculator
|
||||
- branch predictor
|
||||
- comparator
|
||||
- dictionary
|
||||
- lambda
|
||||
- logger
|
||||
- rolex
|
||||
- scanner
|
||||
- spatula
|
||||
program: |
|
||||
run "scenarios/Challenges/_dimsum/cook.sw"
|
||||
- name: patron
|
||||
dir: [0, 1]
|
||||
system: false
|
||||
display:
|
||||
invisible: false
|
||||
attr: blue
|
||||
devices:
|
||||
- ADT calculator
|
||||
- branch predictor
|
||||
- comparator
|
||||
- dictionary
|
||||
- lambda
|
||||
- logger
|
||||
- rolex
|
||||
- scanner
|
||||
- strange loop
|
||||
- fork
|
||||
inventory:
|
||||
- [2, bitcoin]
|
||||
program: |
|
||||
run "scenarios/Challenges/_dimsum/patron.sw"
|
||||
entities:
|
||||
- name: table
|
||||
display:
|
||||
attr: wood
|
||||
char: 't'
|
||||
description:
|
||||
- Pushable table
|
||||
properties: [known, pushable]
|
||||
- name: spatula
|
||||
display:
|
||||
char: 's'
|
||||
description:
|
||||
- Serving utensil for the cart
|
||||
properties: [known, portable]
|
||||
- name: fork
|
||||
display:
|
||||
char: 'k'
|
||||
description:
|
||||
- Eating utensil for patron
|
||||
properties: [known, portable]
|
||||
- name: food
|
||||
display:
|
||||
char: 'f'
|
||||
description:
|
||||
- Food from the cart
|
||||
properties: [known, portable]
|
||||
- name: empty cart
|
||||
display:
|
||||
attr: copper
|
||||
char: 'e'
|
||||
description:
|
||||
- Food cart
|
||||
properties: [known, pushable]
|
||||
- name: full cart
|
||||
display:
|
||||
attr: gold
|
||||
char: 'f'
|
||||
description:
|
||||
- Food cart
|
||||
properties: [known, pushable]
|
||||
recipes:
|
||||
- in:
|
||||
- [1, empty cart]
|
||||
out:
|
||||
- [1, full cart]
|
||||
required:
|
||||
- [1, spatula]
|
||||
- in:
|
||||
- [1, full cart]
|
||||
out:
|
||||
- [1, empty cart]
|
||||
- [1, food]
|
||||
required:
|
||||
- [1, fork]
|
||||
known: [boulder, bitcoin]
|
||||
world:
|
||||
dsl: |
|
||||
{grass}
|
||||
palette:
|
||||
'B': [grass, erase, base]
|
||||
'.': [grass, erase]
|
||||
'S': [dirt, erase]
|
||||
'@': [grass, boulder]
|
||||
'd': [grass, table]
|
||||
'k': [grass, table, cook]
|
||||
'p': [grass, table, patron]
|
||||
's': [grass, empty cart]
|
||||
'x': [stone, erase]
|
||||
upperleft: [0, 0]
|
||||
map: |
|
||||
.@@@.........
|
||||
.@k@@@@@@@@x@
|
||||
.@Bddddddddd@
|
||||
.@dxxxxxxxd@@
|
||||
.@dxSSSSSxd@.
|
||||
.@dxxSxxxxd@.
|
||||
.@dxxxSxxxd@.
|
||||
.@dxxSxxxxd@.
|
||||
.@dxSSSSSxd@.
|
||||
@@dxxxxxxxd@.
|
||||
@ddddddddds@.
|
||||
@x@@@@@@@@p@.
|
||||
.........@@@.
|
@ -1370,7 +1370,7 @@ execConst runChildProg c vs s k = do
|
||||
ensureEquipped itemName = do
|
||||
inst <- use equippedDevices
|
||||
listToMaybe (lookupByName itemName inst)
|
||||
`isJustOrFail` ["You don't have a", indefinite itemName, "equipped."]
|
||||
`isJustOrFail` ["You don't have", indefinite itemName, "equipped."]
|
||||
|
||||
ensureItem :: HasRobotStepState sig m => Text -> Text -> m Entity
|
||||
ensureItem itemName action = do
|
||||
|
@ -237,6 +237,7 @@ testScenarioSolutions rs ui =
|
||||
, testSolution (Sec 10) "Challenges/Sliding Puzzles/3x3"
|
||||
, testSolution Default "Challenges/friend"
|
||||
, testSolution Default "Challenges/pack-tetrominoes"
|
||||
, testSolution (Sec 10) "Challenges/dimsum"
|
||||
, testGroup
|
||||
"Mazes"
|
||||
[ testSolution Default "Challenges/Mazes/easy_cave_maze"
|
||||
|
Loading…
Reference in New Issue
Block a user