Skip to content

Commit

Permalink
recognize structures with rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Dec 10, 2023
1 parent 938aa2c commit abc7a12
Show file tree
Hide file tree
Showing 33 changed files with 254 additions and 69 deletions.
4 changes: 2 additions & 2 deletions data/scenarios/Challenges/Ranching/beekeeping.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ solution: |
run "scenarios/Challenges/Ranching/_beekeeping/solution.sw"
structures:
- name: beehive
recognize: true
recognize: [north]
structure:
palette:
'-': [dirt, honey frame]
Expand All @@ -137,7 +137,7 @@ structures:
b---b
bbbbb
- name: mead hall
recognize: true
recognize: [north]
structure:
palette:
'w': [dirt, wall]
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 @@ -12,3 +12,5 @@
1575-interior-entity-placement.yaml
1575-floorplan-command.yaml
1575-bounding-box-overlap.yaml
1644-rotated-recognition.yaml
1644-rotated-preplacement-recognition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ solution: |
doN 3 (place "boulder"; move;);
structures:
- name: chevron
recognize: true
recognize: [north]
structure:
palette:
'g': [stone, boulder]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: |
Hit *F6* to view the recognizable structures.
Only the subset of the structures marked with
*recognize: true* are browseable.
*recognize: [north]* are browseable.
In particular, the `donut`{=structure} structure is placed
in the map but not displayed in the *F6* dialog.
creative: false
Expand Down Expand Up @@ -53,7 +53,7 @@ structures:
@@@@@
.@@@.
- name: diamond
recognize: true
recognize: [north]
description: "A diamond pattern of flowers"
structure:
mask: '.'
Expand All @@ -68,7 +68,7 @@ structures:
..xxx..
...x...
- name: contraption
recognize: true
recognize: [north]
description: "A device for assembling useful widgets"
structure:
mask: '.'
Expand All @@ -83,7 +83,7 @@ structures:
lIIIgg
rlllgg
- name: precious
recognize: true
recognize: [north]
structure:
mask: '.'
palette:
Expand All @@ -96,7 +96,7 @@ structures:
gsq
qqm
- name: smallish
recognize: true
recognize: [north]
structure:
mask: '.'
palette:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ solution: |
);
structures:
- name: green_jewel
recognize: true
recognize: [north]
structure:
palette:
'g': [stone, pixel (G)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ solution: |
place "silver";
structures:
- name: chessboard
recognize: true
recognize: [north]
structure:
mask: '.'
palette:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ solution: |
place "gold";
structures:
- name: chessboard
recognize: true
recognize: [north]
structure:
mask: '.'
palette:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ solution: |
mkRows height width;
structures:
- name: wooden box
recognize: true
recognize: [north]
structure:
palette:
'b': [stone, board]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ solution: |
place "mithril";
structures:
- name: precious
recognize: true
recognize: [north]
structure:
mask: '.'
palette:
Expand All @@ -46,7 +46,7 @@ structures:
gsq
qqm
- name: smallish
recognize: true
recognize: [north]
structure:
mask: '.'
palette:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ solution: |
place x;
structures:
- name: pigpen
recognize: true
recognize: [north]
structure:
palette:
'b': [stone, board]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ robots:
- treads
structures:
- name: double ring
recognize: true
recognize: [north]
structure:
palette:
's': [ice, tree]
Expand All @@ -68,7 +68,7 @@ structures:
.s.
...
- name: flowerbox
recognize: true
recognize: [north]
structure:
palette:
'f': [ice, flower]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ solution: |
place "gold";
structures:
- name: large
recognize: true
recognize: [north]
structure:
mask: '.'
palette:
Expand All @@ -47,7 +47,7 @@ structures:
ggs
ggs
- name: small
recognize: true
recognize: [north]
structure:
mask: '.'
palette:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ solution: |
place "gold";
structures:
- name: topleft
recognize: true
recognize: [north]
structure:
mask: '.'
palette:
Expand All @@ -48,7 +48,7 @@ structures:
gg
gg
- name: bottomright
recognize: true
recognize: [north]
structure:
mask: '.'
palette:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ solution: |
noop;
structures:
- name: red_jewel
recognize: true
recognize: [north]
structure:
palette:
'r': [stone, pixel (R)]
Expand All @@ -49,7 +49,7 @@ structures:
rrr
rrr
- name: green_jewel
recognize: true
recognize: [north]
structure:
palette:
'g': [stone, pixel (G)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ solution: |
grab;
structures:
- name: chessboard
recognize: true
recognize: [north]
structure:
mask: '.'
palette:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ solution: |
swap "pixel (B)";
structures:
- name: red_jewel
recognize: true
recognize: [north]
structure:
mask: '.'
palette:
Expand All @@ -68,7 +68,7 @@ structures:
gsssg
ggggg
- name: green_jewel
recognize: true
recognize: [north]
structure:
mask: '.'
palette:
Expand All @@ -82,7 +82,7 @@ structures:
gsssg
ggggg
- name: blue_jewel
recognize: true
recognize: [north]
structure:
mask: '.'
palette:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: 1
name: Rotated pre-placed structure recognition
description: |
Pre-placed structure recognition with rotation
creative: false
objectives:
- teaser: Have structure
goal:
- |
Have a `tee`{=structure} structure
condition: |
foundStructure <- structure "tee" 0;
return $ case foundStructure (\_. false) (\_. true);
robots:
- name: base
dir: [1, 0]
devices:
- grabber
- treads
inventory:
- [4, flower]
solution: |
noop;
structures:
- name: tee
recognize: [north, south, east, west]
description: "A tee pattern of flowers"
structure:
mask: '.'
palette:
'x': [stone, flower]
map: |
.x.
xxx
known: [flower]
world:
name: root
dsl: |
{blank}
palette:
'.': [grass]
'x': [stone, flower]
'B': [grass, null, base]
upperleft: [0, 0]
placements:
- src: tee
offset: [2, 0]
orient:
up: east
map: |
B....
.....
.....
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: 1
name: Rotated structure recognition
description: |
Structure recognition with rotation
creative: false
objectives:
- teaser: Build structure
goal:
- |
Build a `tee`{=structure} structure
condition: |
foundStructure <- structure "tee" 0;
return $ case foundStructure (\_. false) (\_. true);
robots:
- name: base
dir: [1, 0]
devices:
- grabber
- treads
inventory:
- [4, flower]
solution: |
move; move;
turn right;
move; move;
place "flower";
structures:
- name: tee
recognize: [north, south, east, west]
description: "A tee pattern of flowers"
structure:
mask: '.'
palette:
'x': [stone, flower]
map: |
.x.
xxx
known: [flower]
world:
name: root
dsl: |
{blank}
palette:
'.': [grass]
'x': [stone, flower]
'B': [grass, null, base]
upperleft: [0, 0]
map: |
B.x..
..xx.
.....
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ robots:
- treads
structures:
- name: red_jewel
recognize: true
recognize: [east]
structure:
mask: '.'
palette:
Expand Down
2 changes: 1 addition & 1 deletion data/schema/named-structure.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"description": "Description of this substructure"
},
"recognize": {
"type": "boolean",
"type": "array",
"description": "Whether this structure participates in automatic recognition when constructed"
},
"structure": {
Expand Down
2 changes: 1 addition & 1 deletion src/Swarm/Game/Scenario.hs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ instance FromJSONE (EntityMap, WorldMap) Scenario where

let mergedNavigation = Navigation mergedWaypoints mergedPortals
structureInfo =
StaticStructureInfo (filter Structure.recognize namedGrids)
StaticStructureInfo (filter Structure.isRecognizable namedGrids)
. M.fromList
. NE.toList
$ NE.map (worldName &&& placedStructures) allWorlds
Expand Down
Loading

0 comments on commit abc7a12

Please sign in to comment.