Work on perhaps replacing FGL with incidence vectors

This commit is contained in:
2025-10-20 13:07:52 +01:00
parent b2fd0543dd
commit c250448d57
6 changed files with 1821 additions and 1798 deletions
+1
View File
@@ -50,6 +50,7 @@ data World = World
, _pnZoning :: IntMap (IntMap [(Int, Point2)]) --Zoning IM.IntMap Creature , _pnZoning :: IntMap (IntMap [(Int, Point2)]) --Zoning IM.IntMap Creature
, _peZoning :: IntMap (IntMap (Set PathEdgeNodes)) , _peZoning :: IntMap (IntMap (Set PathEdgeNodes))
, _incNodeZoning :: IntMap (IntMap [(Int, Point2)]) --Zoning IM.IntMap Creature , _incNodeZoning :: IntMap (IntMap [(Int, Point2)]) --Zoning IM.IntMap Creature
, _incEdgeZoning :: IntMap (IntMap [(Int,Int)]) --Zoning IM.IntMap Creature
, _gsZoning :: IntMap (IntMap IntSet) , _gsZoning :: IntMap (IntMap IntSet)
, _wCam :: Camera , _wCam :: Camera
, _unpauseClock :: Int , _unpauseClock :: Int
+1
View File
@@ -50,6 +50,7 @@ defaultWorld =
, _pnZoning = mempty , _pnZoning = mempty
, _peZoning = mempty , _peZoning = mempty
, _incNodeZoning = mempty , _incNodeZoning = mempty
, _incEdgeZoning = mempty
, _gsZoning = mempty --Zoning IM.empty clZoneSize (zonePos _guPos) , _gsZoning = mempty --Zoning IM.empty clZoneSize (zonePos _guPos)
, _unpauseClock = 0 , _unpauseClock = 0
, _coordinates = mempty , _coordinates = mempty
+4 -2
View File
@@ -51,9 +51,11 @@ generateLevelFromRoomList gr' w =
& pnZoning .~ foldl' (flip zonePn) mempty (labNodes path) & pnZoning .~ foldl' (flip zonePn) mempty (labNodes path)
& peZoning .~ foldl' (flip zonePe) mempty (map fromEdgeTuple $ labEdges path) & peZoning .~ foldl' (flip zonePe) mempty (map fromEdgeTuple $ labEdges path)
& incNodeZoning .~ UV.ifoldl' (\m i p -> zonePn (i,p) m) mempty inodes & incNodeZoning .~ UV.ifoldl' (\m i p -> zonePn (i,p) m) mempty inodes
& incEdgeZoning .~ foldl' (flip (zoneIncPe inodes)) mempty ipairs
where where
(_, path) = pairsToGraph . snapToGrid $ foldMap _rmPath rs pairs = snapToGrid $ foldMap _rmPath rs
(inodes,igraph) = pairsToIncGraph . snapToGrid $ foldMap _rmPath rs (_, path) = pairsToGraph pairs
(inodes,igraph,ipairs) = pairsToIncGraph pairs
rs = map doRoomShift $ IM.elems rs' rs = map doRoomShift $ IM.elems rs'
rs' = mapM shuffleRoomPos gr' & evalState $ _randGen w rs' = mapM shuffleRoomPos gr' & evalState $ _randGen w
+5 -2
View File
@@ -126,8 +126,11 @@ pointTowardsImpulse a b w =
-- --
pairsToIncGraph :: Set.Set (Point2,Point2) pairsToIncGraph :: Set.Set (Point2,Point2)
-> (UV.Vector Point2, V.Vector [(Int,SimpleEdge)]) -> (UV.Vector Point2
pairsToIncGraph pairs = (inodes,incgraph) , V.Vector [(Int,SimpleEdge)]
, [(Int,Int)]
)
pairsToIncGraph pairs = (inodes,incgraph,undefined)
where where
incgraph = V.generate (length im) (\i -> im ^?! ix i) incgraph = V.generate (length im) (\i -> im ^?! ix i)
im = IM.fromListWith (<>) . fmap toedge $ Set.toList pairs im = IM.fromListWith (<>) . fmap toedge $ Set.toList pairs
+13
View File
@@ -1,5 +1,6 @@
module Dodge.Zoning.Pathing where module Dodge.Zoning.Pathing where
import qualified Data.Vector.Unboxed as UV
import Data.Foldable import Data.Foldable
import Data.Set (Set) import Data.Set (Set)
import qualified Data.Set as Set import qualified Data.Set as Set
@@ -8,6 +9,7 @@ import Dodge.Zoning.Base
import Dodge.Zoning.Common import Dodge.Zoning.Common
import Geometry import Geometry
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import Control.Lens
pnsNearPoint :: Point2 -> World -> [(Int, Point2)] pnsNearPoint :: Point2 -> World -> [(Int, Point2)]
pnsNearPoint = nearPoint pnZoneSize _pnZoning pnsNearPoint = nearPoint pnZoneSize _pnZoning
@@ -47,6 +49,9 @@ pesNearCirc p r = pesNearRect (p +.+ V2 r r) (p -.- V2 r r)
peZoneSize :: Float peZoneSize :: Float
peZoneSize = 50 peZoneSize = 50
zoneOfIncPe :: UV.Vector Point2 -> (Int,Int) -> [Int2]
zoneOfIncPe m (i,j) = zoneOfSeg peZoneSize (m ^?! ix i) (m ^?! ix j)
zoneOfPe :: PathEdgeNodes -> [Int2] zoneOfPe :: PathEdgeNodes -> [Int2]
zoneOfPe (PathEdgeNodes _ _ pe) = zoneOfSeg peZoneSize (_peStart pe) (_peEnd pe) zoneOfPe (PathEdgeNodes _ _ pe) = zoneOfSeg peZoneSize (_peStart pe) (_peEnd pe)
@@ -57,3 +62,11 @@ zonePe ::
zonePe pe im = foldl' f im (zoneOfPe pe) zonePe pe im = foldl' f im (zoneOfPe pe)
where where
f im' i2 = zoneMonoid i2 (Set.singleton pe) im' f im' i2 = zoneMonoid i2 (Set.singleton pe) im'
zoneIncPe :: UV.Vector Point2 ->
(Int,Int) ->
IM.IntMap (IM.IntMap [(Int,Int)]) ->
IM.IntMap (IM.IntMap [(Int,Int)])
zoneIncPe v pe im = foldl' f im (zoneOfIncPe v pe)
where
f im' i2 = zoneMonoid i2 [pe] im'
+1797 -1794
View File
File diff suppressed because it is too large Load Diff