Skip to content

Commit 1c0fa23

Browse files
Ignore installed entities
1 parent d7a04e4 commit 1c0fa23

File tree

2 files changed

+2
-23
lines changed

2 files changed

+2
-23
lines changed

src/Swarm/Game/State.hs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ module Swarm.Game.State (
4242
availableRecipes,
4343
availableRecipesNewCount,
4444
allDiscoveredEntities,
45-
allInstalledDevices,
4645
gensym,
4746
randGen,
4847
adjList,
@@ -191,7 +190,6 @@ data GameState = GameState
191190
_waitingRobots :: Map Integer [RID]
192191
, _robotsByLocation :: Map (V2 Int64) IntSet
193192
, _allDiscoveredEntities :: Inventory
194-
, _allInstalledDevices :: Inventory
195193
, _availableRecipes :: [Recipe Entity]
196194
, _availableRecipesNewCount :: Int
197195
, _gensym :: Int
@@ -259,9 +257,6 @@ robotsByLocation :: Lens' GameState (Map (V2 Int64) IntSet)
259257
-- | The list of entities that have been discovered.
260258
allDiscoveredEntities :: Lens' GameState Inventory
261259

262-
-- | The list of devices that have been installed once.
263-
allInstalledDevices :: Lens' GameState Inventory
264-
265260
-- | The list of available recipes.
266261
availableRecipes :: Lens' GameState [Recipe Entity]
267262

@@ -463,7 +458,6 @@ initGameState cmdlineSeed scenarioToLoad toRun = do
463458
, _availableRecipes = mempty
464459
, _availableRecipesNewCount = 0
465460
, _allDiscoveredEntities = empty
466-
, _allInstalledDevices = empty
467461
, _activeRobots = IS.empty
468462
, _waitingRobots = M.empty
469463
, _gensym = 0

src/Swarm/Game/Step.hs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,6 @@ execConst c vs s k = do
859859
-- either robot's inventory
860860
when (focusedID == myID || focusedID == otherID) flagRedraw
861861

862-
updateInstalledDevice item
863862
return $ Out VUnit s k
864863
_ -> badConst
865864
Make -> case vs of
@@ -1371,7 +1370,7 @@ execConst c vs s k = do
13711370
[VBool b] -> return $ Out (VBool (not b)) s k
13721371
_ -> badConst
13731372
Neg -> case vs of
1374-
[VInt n] -> return $ Out (VInt (- n)) s k
1373+
[VInt n] -> return $ Out (VInt (-n)) s k
13751374
_ -> badConst
13761375
Eq -> returnEvalCmp
13771376
Neq -> returnEvalCmp
@@ -1643,23 +1642,9 @@ updateDiscoveredEntities e = do
16431642
then pure ()
16441643
else do
16451644
let newAllDiscovered = E.insertCount 1 e allDiscovered
1646-
allDevices <- use allInstalledDevices
1647-
updateAvailableRecipes (newAllDiscovered, allDevices) e
1645+
updateAvailableRecipes (newAllDiscovered, newAllDiscovered) e
16481646
allDiscoveredEntities .= newAllDiscovered
16491647

1650-
-- | Update the global list of installed devices, and check for new recipes.
1651-
updateInstalledDevice :: (Has (State GameState) sig m, Has (State Robot) sig m) => Entity -> m ()
1652-
updateInstalledDevice e = do
1653-
allDevices <- use allInstalledDevices
1654-
if E.contains0plus e allDevices
1655-
then pure ()
1656-
else do
1657-
let newAllDevices = E.insertCount 1 e allDevices
1658-
-- Check every known entities to see if the new device enables new recipes
1659-
allDiscovered <- use allDiscoveredEntities
1660-
traverse_ (updateAvailableRecipes (allDiscovered, newAllDevices) . snd) (elems allDiscovered)
1661-
allInstalledDevices .= newAllDevices
1662-
16631648
-- | Update the availableRecipes list.
16641649
-- This implementation is not efficient:
16651650
-- * Every time we discover a new entity, we iterate through the entire list of recipes to see which ones we can make.

0 commit comments

Comments
 (0)