From a33eafa28b6d8c473c835e442c436948e00a7351 Mon Sep 17 00:00:00 2001 From: Karl Ostmo Date: Mon, 26 Feb 2024 19:17:01 -0800 Subject: [PATCH] wip2 --- src/swarm-engine/Swarm/Game/Step/Util/Command.hs | 4 ++-- src/swarm-scenario/Swarm/Game/Robot.hs | 16 ++-------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/swarm-engine/Swarm/Game/Step/Util/Command.hs b/src/swarm-engine/Swarm/Game/Step/Util/Command.hs index d0a73620f9..0705073de2 100644 --- a/src/swarm-engine/Swarm/Game/Step/Util/Command.hs +++ b/src/swarm-engine/Swarm/Game/Step/Util/Command.hs @@ -118,8 +118,8 @@ ensureCanExecute c = Incapable FixByObtainConsumables (expenseToRequirement $ NE.head costs) (TConst c) -- Consume the inventory Just feasibleRecipe -> - forM_ (ingredients . useCost $ feasibleRecipe) $ \(c, e) -> - robotInventory %= deleteCount c e + forM_ (ingredients . useCost $ feasibleRecipe) $ \(cnt, e) -> + robotInventory %= deleteCount cnt e expenseToRequirement :: DeviceUseCost Entity -> R.Requirements expenseToRequirement (DeviceUseCost (ExerciseCost ingdts) d) = diff --git a/src/swarm-scenario/Swarm/Game/Robot.hs b/src/swarm-scenario/Swarm/Game/Robot.hs index 3a43121d97..5de30547f8 100644 --- a/src/swarm-scenario/Swarm/Game/Robot.hs +++ b/src/swarm-scenario/Swarm/Game/Robot.hs @@ -136,16 +136,6 @@ type instance RobotLogUpdatedMember 'TemplateRobot = () data RobotR (phase :: RobotPhase) = RobotR { _robotEntity :: Entity , _equippedDevices :: Inventory - , _globalEntityMap :: EntityMap - -- ^ A cached reference to the global entity map, which is static - -- from scenario parse time. - -- This is used to convert entity names in - -- "capability exercise" recipes to actual entities. - -- We need "actual entities" instead of mere entity names - -- to make use of the 'Swarm.Game.Recipe.findLacking' function - -- that determines whether recipe inputs are satisfied by a - -- robot's inventory. - -- TODO: Are we sure we need this after all? , _robotCapabilities :: MultiEntityCapabilities Entity -- ^ A cached view of the capabilities this robot has. -- Automatically generated from '_equippedDevices'. @@ -172,7 +162,7 @@ deriving instance (Eq (RobotLocation phase), Eq (RobotID phase), Eq (RobotMachin -- See https://byorgey.wordpress.com/2021/09/17/automatically-updated-cached-views-with-lens/ -- for the approach used here with lenses. -makeLensesExcluding ['_globalEntityMap, '_robotCapabilities, '_equippedDevices, '_robotLog, '_robotLogUpdated, '_robotContext, '_machine, '_activityCounts] ''RobotR +makeLensesExcluding ['_robotCapabilities, '_equippedDevices, '_robotLog, '_robotLogUpdated, '_robotContext, '_machine, '_activityCounts] ''RobotR -- | A template robot, i.e. a template robot record without a unique ID number, -- and possibly without a location. @@ -328,7 +318,6 @@ walkabilityContext = to $ -- | A general function for creating robots. mkRobot :: - EntityMap -> Maybe Int -> -- | Name of the robot. Text -> @@ -355,14 +344,13 @@ mkRobot :: -- | Creation date TimeSpec -> TRobot -mkRobot em pid name descr loc dir disp m devs inv sys heavy unwalkables ts = +mkRobot pid name descr loc dir disp m devs inv sys heavy unwalkables ts = RobotR { _robotEntity = mkEntity disp name descr [] mempty & entityOrientation ?~ dir & entityInventory .~ fromElems inv , _equippedDevices = inst - , _globalEntityMap = em , _robotCapabilities = inventoryCapabilities em inst , _robotLog = () , _robotLogUpdated = ()