-
Notifications
You must be signed in to change notification settings - Fork 54
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
15 changed files
with
288 additions
and
18 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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
version: 1 | ||
name: Waypoints for nested structures | ||
description: | | ||
Demonstrate behavior of waypoints across structure overlays | ||
robots: | ||
- name: base | ||
loc: [0, 4] | ||
dir: [1, 0] | ||
known: [tree, flower, sand, bit (0), bit (1)] | ||
world: | ||
upperleft: [-4, 7] | ||
default: [blank] | ||
palette: | ||
'.': [grass] | ||
'*': [stone, flower] | ||
'┌': [stone, upper left corner] | ||
'┐': [stone, upper right corner] | ||
'└': [stone, lower left corner] | ||
'┘': [stone, lower right corner] | ||
'─': [stone, horizontal wall] | ||
'│': [stone, vertical wall] | ||
structures: | ||
- name: bitpair | ||
structure: | ||
palette: | ||
'0': [stone, bit (0)] | ||
'1': [stone, bit (1)] | ||
map: | | ||
1 | ||
0 | ||
waypoints: | ||
- name: bitpair_bottom | ||
loc: [0, -1] | ||
- name: minibox | ||
structure: | ||
palette: | ||
'.': [stone] | ||
's': [stone, sand] | ||
placements: | ||
- src: bitpair | ||
offset: [1, 0] | ||
waypoints: | ||
- name: minibox_corner | ||
loc: [0, 0] | ||
map: | | ||
s.s | ||
s.s | ||
- name: bigbox | ||
structure: | ||
palette: | ||
'.': [stone] | ||
'T': [stone, tree] | ||
waypoints: | ||
- name: bigbox_middle | ||
loc: [2, -3] | ||
map: | | ||
TTTTTT | ||
T.T.T. | ||
.T.T.T | ||
TTTTTT | ||
placements: | ||
- src: bigbox | ||
offset: [1, -1] | ||
- src: bigbox | ||
offset: [7, -5] | ||
- src: minibox | ||
offset: [1, -7] | ||
waypoints: | ||
- name: meadow | ||
loc: [12, -1] | ||
portals: | ||
- entrance: bitpair_bottom | ||
exitInfo: | ||
exit: bigbox_middle | ||
- entrance: minibox_corner | ||
exitInfo: | ||
exit: meadow | ||
map: | | ||
┌────────────┐ | ||
│*..*..*..*..│ | ||
│.*..*..*..*.│ | ||
│..*..*..*..*│ | ||
│*..*..*..*..│ | ||
│.*..*..*..*.│ | ||
│..*..*..*..*│ | ||
│*..*..*..*..│ | ||
│.*..*..*..*.│ | ||
└────────────┘ |
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 |
---|---|---|
|
@@ -82,6 +82,7 @@ | |
"time" | ||
"scout" | ||
"whereami" | ||
"waypoint" | ||
"detect" | ||
"resonate" | ||
"density" | ||
|
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
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,25 @@ | ||
-- | | ||
-- SPDX-License-Identifier: BSD-3-Clause | ||
module Swarm.Game.Scenario.Portal where | ||
|
||
import Swarm.Game.Scenario.Structure | ||
import Data.Aeson | ||
import Data.Text (Text) | ||
import GHC.Generics (Generic) | ||
|
||
-- | Note: The primary overworld shall use | ||
-- the reserved name \"root\". | ||
newtype SubworldName = SubworldName Text | ||
deriving (Show, Eq, Ord, Generic, FromJSON) | ||
|
||
data PortalExit = PortalExit { | ||
exit :: WaypointName | ||
-- | Note: 'Nothing' indicates that references a waypoint within the same subworld. | ||
, subworldName :: Maybe SubworldName | ||
} deriving (Show, Eq, Generic, FromJSON) | ||
|
||
data Portal = Portal | ||
{ entrance :: WaypointName | ||
, exitInfo :: PortalExit | ||
} | ||
deriving (Show, Eq, Generic, FromJSON) |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
-- | | ||
-- SPDX-License-Identifier: BSD-3-Clause | ||
module Swarm.Game.Scenario.Subworld where | ||
|
||
import Data.Aeson | ||
import Swarm.Game.Entity | ||
import Swarm.Game.Scenario.RobotLookup | ||
import Swarm.Game.Scenario.WorldDescription | ||
import Swarm.Util.Yaml | ||
import Swarm.Game.Scenario.Portal | ||
|
||
data Subworld = Subworld | ||
{ name :: SubworldName | ||
, portals :: [Portal] | ||
, world :: WorldDescription | ||
} | ||
deriving (Eq, Show) | ||
|
||
instance FromJSONE EntityMap Subworld where | ||
parseJSONE = withObjectE "subworld" $ \v -> do | ||
n <- liftE (v .: "name") | ||
c <- liftE (v .: "connectivity") | ||
let rsMap = buildRobotMap [] | ||
w <- localE (,rsMap) (v ..: "world") | ||
return $ Subworld n c w |
Oops, something went wrong.