about summary refs log tree commit diff
path: root/users/glittershark/xanthous/src/Xanthous/Data.hs
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-06-28T23·33-0400
committerglittershark <grfn@gws.fyi>2020-06-28T23·38+0000
commitbf9b09bd8c63261758140d51f24617c6f05af392 (patch)
tree4cf43fa084a73cc2e6b51e3f7c67ac1e6a80459b /users/glittershark/xanthous/src/Xanthous/Data.hs
parent6c7e14d2dcd3a3b124dc035e8feb8e79534cd66a (diff)
feat(xan): Generate random villages r/1111
This algorithm is a little rough around the edges right now, but
generally the idea is we find a relatively closed-off region of the map,
and place rooms randomly on it, expanding them until they run into each
other, then we put doors in the walls of the rooms and a single door
opening into the region. Later on, we'll generate friendly (or
unfriendly!) NPCs to put in those rooms.

Change-Id: Ic989b9905f55ad92a01fdf6db11aa57afb4ce383
Reviewed-on: https://cl.tvl.fyi/c/depot/+/726
Reviewed-by: glittershark <grfn@gws.fyi>
Diffstat (limited to 'users/glittershark/xanthous/src/Xanthous/Data.hs')
-rw-r--r--users/glittershark/xanthous/src/Xanthous/Data.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/users/glittershark/xanthous/src/Xanthous/Data.hs b/users/glittershark/xanthous/src/Xanthous/Data.hs
index 67173cc89646..031815b8fba4 100644
--- a/users/glittershark/xanthous/src/Xanthous/Data.hs
+++ b/users/glittershark/xanthous/src/Xanthous/Data.hs
@@ -79,8 +79,17 @@ module Xanthous.Data
   , edges
   , neighborDirections
   , neighborPositions
+  , neighborCells
   , arrayNeighbors
   , rotations
+  , HasTopLeft(..)
+  , HasTop(..)
+  , HasTopRight(..)
+  , HasLeft(..)
+  , HasRight(..)
+  , HasBottomLeft(..)
+  , HasBottom(..)
+  , HasBottomRight(..)
 
     -- *
   , Hitpoints(..)
@@ -439,6 +448,9 @@ neighborDirections = Neighbors
 neighborPositions :: Num a => Position' a -> Neighbors (Position' a)
 neighborPositions pos = (`move` pos) <$> neighborDirections
 
+neighborCells :: Num a => (a, a) -> Neighbors (a, a)
+neighborCells = map (view _Position) . neighborPositions . review _Position
+
 arrayNeighbors
   :: (IArray a e, Ix i, Num i)
   => a (i, i) e