Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Dec 19, 2023
1 parent 253e3a4 commit 6896ef0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Swarm/Web/Worldview.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Swarm.Game.State.Robot (viewCenter)
import Swarm.Game.Universe (planar)
import Swarm.Game.World.Render
import Swarm.TUI.View.CellDisplay (getTerrainEntityColor)
import Swarm.Util.OccurrenceIndex
import Swarm.Util.OccurrenceEncoder

data GridResponse = GridResponse
{ isPlaying :: Bool
Expand All @@ -36,7 +36,7 @@ getCellGrid ::
AreaDimensions ->
CellGrid
getCellGrid myScenario gs requestedSize =
CellGrid indexGrid $ getIndices indexMap
CellGrid indexGrid $ getIndices encoding
where
vc = gs ^. robotInfo . viewCenter
dg = getDisplayGrid (vc ^. planar) myScenario gs (Just requestedSize)
Expand All @@ -47,7 +47,7 @@ getCellGrid myScenario gs requestedSize =
asHex = HexColor . T.pack . sRGB24show . asColour

f = asHex . maybe (RGB 0 0 0) (flattenBg . fromHiFi) . getTerrainEntityColor aMap
(indexGrid, indexMap) = runState (mapM (encodeOccurrence . f) dg) emptyEncoder
(indexGrid, encoding) = runState (mapM (encodeOccurrence . f) dg) emptyEncoder

data CellGrid = CellGrid
{ coords :: Grid IM.Key
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- |
-- SPDX-License-Identifier: BSD-3-Clause
module Swarm.Util.OccurrenceIndex (
module Swarm.Util.OccurrenceEncoder (
Encoder,
encodeOccurrence,
getIndices,
Expand All @@ -19,7 +19,8 @@ newtype Encoder a = Encoder (Map a Int)
emptyEncoder :: Ord a => Encoder a
emptyEncoder = Encoder mempty

-- | Indices are guaranteed to be contiguous.
-- | Indices are guaranteed to be contiguous
-- from @[0..N]@.
getIndices :: Encoder a -> [a]
getIndices (Encoder m) = map fst $ sortOn snd $ M.toList m

Expand Down
4 changes: 2 additions & 2 deletions swarm.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ library swarm-util
Swarm.Util
Swarm.Util.Erasable
Swarm.Util.Lens
Swarm.Util.OccurrenceIndex
Swarm.Util.OccurrenceEncoder
Swarm.Util.Parse
Swarm.Util.RingBuffer
Swarm.Util.UnitInterval
Expand Down Expand Up @@ -296,7 +296,7 @@ library
, Swarm.Util
, Swarm.Util.Erasable
, Swarm.Util.Lens
, Swarm.Util.OccurrenceIndex
, Swarm.Util.OccurrenceEncoder
, Swarm.Util.Parse
, Swarm.Util.RingBuffer
, Swarm.Util.UnitInterval
Expand Down

0 comments on commit 6896ef0

Please sign in to comment.