Skip to content

Commit

Permalink
Use robotMap directly instead of addRobot (#1378)
Browse files Browse the repository at this point in the history
Closes #1372
  • Loading branch information
kostmo authored Jul 18, 2023
1 parent 485e6ac commit 4491f10
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 4491f10

Please sign in to comment.