Skip to content

Commit

Permalink
wip2
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Feb 27, 2024
1 parent a99e41c commit a33eafa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/swarm-engine/Swarm/Game/Step/Util/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand Down
16 changes: 2 additions & 14 deletions src/swarm-scenario/Swarm/Game/Robot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand All @@ -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.
Expand Down Expand Up @@ -328,7 +318,6 @@ walkabilityContext = to $

-- | A general function for creating robots.
mkRobot ::
EntityMap ->
Maybe Int ->
-- | Name of the robot.
Text ->
Expand All @@ -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 = ()
Expand Down

0 comments on commit a33eafa

Please sign in to comment.