Skip to content

Commit

Permalink
Use entityAt instead of getContentAt (#1774)
Browse files Browse the repository at this point in the history
Follow-up to #1724.
  • Loading branch information
kostmo authored Feb 20, 2024
1 parent 7c991f7 commit 0d65a04
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/swarm-engine/Swarm/Game/Step/Const.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Control.Effect.Error
import Control.Effect.Lens
import Control.Effect.Lift
import Control.Lens as Lens hiding (Const, distrib, from, parts, use, uses, view, (%=), (+=), (.=), (<+=), (<>=))
import Control.Monad (forM, forM_, guard, msum, unless, when)
import Control.Monad (filterM, forM, forM_, guard, msum, unless, when)
import Data.Bifunctor (second)
import Data.Bool (bool)
import Data.Char (chr, ord)
Expand Down Expand Up @@ -84,7 +84,6 @@ import Swarm.Game.Step.Util.Inspect
import Swarm.Game.Tick
import Swarm.Game.Universe
import Swarm.Game.Value
import Swarm.Game.World (locToCoords)
import Swarm.Language.Capability
import Swarm.Language.Context hiding (delete)
import Swarm.Language.Key (parseKeyComboFull)
Expand All @@ -97,7 +96,6 @@ import Swarm.Language.Text.Markdown qualified as Markdown
import Swarm.Language.Value
import Swarm.Log
import Swarm.Util hiding (both)
import Swarm.Util.Content (getContentAt)
import Swarm.Util.Effect (throwToMaybe)
import Swarm.Util.Lens (inherit)
import Witch (From (from), into)
Expand Down Expand Up @@ -291,9 +289,8 @@ execConst runChildProg c vs s k = do
-- to spawn near the target location.
omni <- isPrivilegedBot
unless omni $ do
w <- use (landscape . multiWorld)
let area = map (<$ nextLoc) $ getLocsInArea (nextLoc ^. planar) 5
emptyLocs = filter (\cl -> isNothing . snd $ getContentAt w (locToCoords <$> cl)) area
emptyLocs <- filterM (fmap isNothing . entityAt) area
randomLoc <- weightedChoice (const 1) emptyLocs
es <- uses (landscape . entityMap) allEntities
randomEntity <- weightedChoice (const 1) es
Expand Down

0 comments on commit 0d65a04

Please sign in to comment.