Skip to content

Commit

Permalink
Use robotMap directly instead of addRobot
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Jul 18, 2023
1 parent 485e6ac commit 798f634
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Swarm/Game/Step.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1584,12 +1584,16 @@ execConst c vs s k = do
| otherwise -> es |> e
let addToRobotLog :: Has (State GameState) sgn m => Robot -> m ()
addToRobotLog r = do
r' <- execState r $ do
maybeRidLoc <- evalState r $ do
hasLog <- hasCapability CLog
hasListen <- hasCapability CListen
loc' <- use robotLocation
when (hasLog && hasListen) (robotLog %= addLatestClosest loc')
addRobot r'
rid <- use robotID
return $ do
guard $ hasLog && hasListen
Just (rid, loc')
forM_ maybeRidLoc $ \(rid, loc') ->
robotMap . at rid . _Just . robotLog %= addLatestClosest loc'
robotsAround <-
if isPrivileged
then use $ robotMap . to IM.elems
Expand Down

0 comments on commit 798f634

Please sign in to comment.