Skip to content

Commit

Permalink
Merge branch 'main' into windows-support
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Nov 14, 2023
2 parents c2c9079 + bd2de6c commit 9b6e096
Show file tree
Hide file tree
Showing 31 changed files with 306 additions and 51 deletions.
9 changes: 9 additions & 0 deletions data/entities.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,15 @@
A circuit is needed for constructing various "smart" devices.
properties: [portable]

- name: blueprint
display:
attr: blue
char: 'B'
description:
- Locate and analyze structures placed in the world.
properties: [portable]
capabilities: [structure]

- name: drill bit
display:
attr: entity
Expand Down
2 changes: 2 additions & 0 deletions data/scenarios/Testing/1575-structure-recognizer/00-ORDER.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
1575-remove-structure.yaml
1575-swap-structure.yaml
1575-placement-occlusion.yaml
1575-interior-entity-placement.yaml
1575-floorplan-command.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
version: 1
name: Structure browser
description: |
Hit F6 to view the recognizable structures.
Hit *F6* to view the recognizable structures.
Only the subset of the structures marked with
"recognize: true" are browseable.
In particular, the "donut" structure is placed
in the map but not displayed in the F6 dialog.
*recognize: true* are browseable.
In particular, the `donut`{=structure} structure is placed
in the map but not displayed in the *F6* dialog.
creative: false
objectives:
- teaser: Build structure
goal:
- |
Build a "precious" structure
Build a `precious`{=structure} structure
condition: |
foundStructure <- structure "precious" 0;
return $ case foundStructure (\_. false) (\_. true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ objectives:
- teaser: Build 12 structures
goal:
- |
Build 12 copies of the "green_jewel" structure
Build 12 copies of the `green_jewel`{=structure} structure
condition: |
foundGreen <- structure "green_jewel" 0;
return $ case foundGreen (\_. false) (\x. fst x >= 12);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: |
should not be counted until all three are placed.
creative: false
objectives:
- teaser: Build 2 chessboards
- teaser: Build 2 `chessboard`{=structure}s
prerequisite:
not: premature_win
goal:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: |
structure template.
creative: false
objectives:
- teaser: Build 2 chessboards
- teaser: Build 2 `chessboard`{=structure}s
prerequisite:
not: premature_win
goal:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
version: 1
name: Floorplan command
description: |
Query the dimensions of a structure
template to build one.
creative: false
objectives:
- teaser: Build structure
goal:
- |
Build a `wooden box`{=structure} structure.
condition: |
def isRight = \x. case x (\_. false) (\_. true); end;
foundBox <- structure "wooden box" 0;
return $ isRight foundBox;
robots:
- name: base
dir: [1, 0]
devices:
- ADT calculator
- blueprint
- branch predictor
- comparator
- dictionary
- grabber
- logger
- treads
inventory:
- [100, board]
solution: |
def doN = \n. \f. if (n > 0) {f; doN (n - 1) f} {}; end;
def mkRow = \width.
doN width $ (place "board"; move;);
turn back;
doN width move;
end;
def mkRows = \height. \width.
doN height $ (mkRow width; turn left; move; turn left);
end;
dims <- floorplan "wooden box";
let width = fst dims in
let height = snd dims in
mkRows height width;
structures:
- name: wooden box
recognize: true
structure:
palette:
'b': [stone, board]
map: |
bbbbbbb
bbbbbbb
bbbbbbb
bbbbbbb
bbbbbbb
known: [board]
world:
dsl: |
{blank}
palette:
'.': [grass, erase]
'B': [grass, erase, base]
upperleft: [0, 0]
map: |
..........
.B........
..........
..........
..........
..........
..........
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ objectives:
- teaser: Build structure
goal:
- |
Build a "precious" structure
Build a `precious`{=structure} structure
condition: |
foundStructure <- structure "precious" 0;
return $ case foundStructure (\_. false) (\_. true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
version: 1
name: Structure recognition - interior space
description: |
Entities can be added and removed
on empty cells within the rectangular
boundary of an already-placed structure without
affecting its recognition status.
Additionally, recognition of statically-placed
structures at scenario initialization is also
unaffected by interior entities.
However, any such "contaminating" entities
will prevent the recognition of a structure
when constructed by a robot.
creative: false
objectives:
- teaser: Replace rock
prerequisite: grab_rock
goal:
- |
Place the `rock`{=entity} entity back inside the `pigpen`{=structure}.
condition: |
foundBox <- structure "pigpen" 0;
case foundBox (\_. return false) (\struc.
let structPos = snd struc in
j <- robotnamed "judge";
as j {
structBounds <- floorplan "pigpen";
// Move to bottom-left corner
teleport self structPos;
rockCount <- resonate "rock" ((0, 0), structBounds);
return $ rockCount > 0;
}
);
- teaser: Grab rock
id: grab_rock
prerequisite: prerecognized
goal:
- |
Grab an entity from inside a `pigpen`{=structure} structure.
condition: |
as base {
has "rock";
}
- teaser: Prerecognize
id: prerecognized
goal:
- |
`pigpen`{=structure} structure should be recognized upon initialization,
even with an extraneous entity within its bounds.
condition: |
def isRight = \x. case x (\_. false) (\_. true); end;
foundBox <- structure "pigpen" 0;
return $ isRight foundBox;
robots:
- name: base
dir: [1, 0]
devices:
- ADT calculator
- blueprint
- grabber
- logger
- treads
- name: judge
dir: [1, 0]
system: true
display:
invisible: true
solution: |
move; move;
x <- grab;
move;
place x;
structures:
- name: pigpen
recognize: true
structure:
palette:
'b': [stone, board]
mask: '.'
map: |
bbbb
b..b
b..b
bbbb
known: [board, rock]
world:
dsl: |
{blank}
placements:
- src: pigpen
offset: [1, 0]
- src: pigpen
offset: [3, -6]
palette:
'.': [grass, erase]
'B': [grass, erase, base]
'r': [grass, rock]
'j': [grass, erase, judge]
upperleft: [-7, 3]
map: |
j.....
......
B.r...
......
......
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ objectives:
prerequisite: grab_tree
goal:
- |
Replace tree after grabbing.
Structure should be recognized again.
Replace `tree`{=entity} after grabbing.
The `double ring`{=structure} structure should be recognized again.
condition: |
foundStructure <- structure "double ring" 0;
return $ case foundStructure (\_. false) (\_. true);
Expand All @@ -29,7 +29,7 @@ objectives:
id: grab_tree
goal:
- |
Grab a tree
Grab a `tree`{=entity}
condition: |
as base {
has "tree";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ objectives:
not: wrong_structure
goal:
- |
Build a structure
Build a `topleft`{=structure} structure
condition: |
foundStructure <- structure "topleft" 0;
return $ case foundStructure (\_. false) (\_. true);
Expand All @@ -19,7 +19,7 @@ objectives:
optional: true
goal:
- |
The "bottomright" structure shouldn't be recognized.
The `bottomright`{=structure} structure shouldn't be recognized.
condition: |
foundStructure <- structure "bottomright" 0;
return $ case foundStructure (\_. false) (\_. true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ objectives:
not: complete_red_structure
goal:
- |
Build a "green_jewel" structure
Build a `green_jewel`{=structure} structure
condition: |
def isRight = \x. case x (\_. false) (\_. true); end;
Expand All @@ -22,7 +22,7 @@ objectives:
teaser: Complete red structure
goal:
- |
A "red_jewel" structure should not be recognized
A `red_jewel`{=structure} structure should not be recognized
condition: |
def isRight = \x. case x (\_. false) (\_. true); end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ objectives:
teaser: Complete structure
goal:
- |
Build a structure
Build a `chessboard`{=structure} structure
condition: |
foundStructure <- structure "chessboard" 0;
return $ case foundStructure (\_. false) (\_. true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ objectives:
prerequisite: complete_green_structure
goal:
- |
Build a "blue_jewel" structure
Build a `blue_jewel`{=structure} structure
condition: |
def isRight = \x. case x (\_. false) (\_. true); end;
Expand All @@ -22,7 +22,7 @@ objectives:
prerequisite: complete_red_structure
goal:
- |
Build a "green_jewel" structure
Build a `green_jewel`{=structure} structure
condition: |
def isRight = \x. case x (\_. false) (\_. true); end;
Expand All @@ -33,7 +33,7 @@ objectives:
teaser: Complete red structure
goal:
- |
Build a "red_jewel" structure
Build a `red_jewel`{=structure} structure
condition: |
def isRight = \x. case x (\_. false) (\_. true); end;
Expand Down
1 change: 1 addition & 0 deletions editors/emacs/swarm-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"whereami"
"waypoint"
"structure"
"floorplan"
"detect"
"resonate"
"density"
Expand Down
2 changes: 1 addition & 1 deletion editors/vim/swarm.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syn keyword Keyword def end let in require
syn keyword Builtins self parent base if inl inr case fst snd force undefined fail not format chars split charat tochar key
syn keyword Command noop wait selfdestruct move backup path push stride turn grab harvest ignite place ping give equip unequip make has equipped count drill use build salvage reprogram say listen log view appear create halt time scout whereami waypoint structure detect resonate density sniff chirp watch surveil heading blocked scan upload ishere isempty meet meetall whoami setname random run return try swap atomic instant installkeyhandler teleport as robotnamed robotnumbered knows
syn keyword Command noop wait selfdestruct move backup path push stride turn grab harvest ignite place ping give equip unequip make has equipped count drill use build salvage reprogram say listen log view appear create halt time scout whereami waypoint structure floorplan detect resonate density sniff chirp watch surveil heading blocked scan upload ishere isempty meet meetall whoami setname random run return try swap atomic instant installkeyhandler teleport as robotnamed robotnumbered knows
syn keyword Direction east north west south down forward left back right
syn keyword Type int text dir bool cmd void unit actor

Expand Down
2 changes: 1 addition & 1 deletion editors/vscode/syntaxes/swarm.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
},
{
"name": "keyword.other",
"match": "\\b(?i)(self|parent|base|if|inl|inr|case|fst|snd|force|undefined|fail|not|format|chars|split|charat|tochar|key|noop|wait|selfdestruct|move|backup|path|push|stride|turn|grab|harvest|ignite|place|ping|give|equip|unequip|make|has|equipped|count|drill|use|build|salvage|reprogram|say|listen|log|view|appear|create|halt|time|scout|whereami|waypoint|structure|detect|resonate|density|sniff|chirp|watch|surveil|heading|blocked|scan|upload|ishere|isempty|meet|meetall|whoami|setname|random|run|return|try|swap|atomic|instant|installkeyhandler|teleport|as|robotnamed|robotnumbered|knows)\\b"
"match": "\\b(?i)(self|parent|base|if|inl|inr|case|fst|snd|force|undefined|fail|not|format|chars|split|charat|tochar|key|noop|wait|selfdestruct|move|backup|path|push|stride|turn|grab|harvest|ignite|place|ping|give|equip|unequip|make|has|equipped|count|drill|use|build|salvage|reprogram|say|listen|log|view|appear|create|halt|time|scout|whereami|waypoint|structure|floorplan|detect|resonate|density|sniff|chirp|watch|surveil|heading|blocked|scan|upload|ishere|isempty|meet|meetall|whoami|setname|random|run|return|try|swap|atomic|instant|installkeyhandler|teleport|as|robotnamed|robotnumbered|knows)\\b"
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ mkAutomatons xs =
grids = map extractGrid xs

process g = StructureInfo g . histogram . concatMap catMaybes $ entityGrid g
infos = map process grids
infos = M.fromList $ map (name . originalDefinition &&& process) grids

extractGrid :: NamedGrid (Maybe Cell) -> StructureWithGrid
extractGrid x = StructureWithGrid x $ getEntityGrid $ structure x
Expand Down
Loading

0 comments on commit 9b6e096

Please sign in to comment.