Skip to content

Commit

Permalink
fix benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Jul 17, 2023
1 parent de9ac1e commit 9a4ffd5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions bench/Benchmark.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import Control.Monad.Except (runExceptT)
import Control.Monad.State (evalStateT, execStateT)
import Criterion.Main (Benchmark, bench, bgroup, defaultConfig, defaultMainWith, whnfAppIO)
import Criterion.Types (Config (timeLimit))
import Data.Map qualified as M
import Swarm.Game.CESK (emptyStore, initMachine)
import Swarm.Game.Display (defaultRobotDisplay)
import Swarm.Game.Location
import Swarm.Game.Robot (TRobot, mkRobot)
import Swarm.Game.State (GameState, addTRobot, creativeMode, world)
import Swarm.Game.State (GameState, addTRobot, creativeMode, multiWorld)
import Swarm.Game.Step (gameTick)
import Swarm.Game.Terrain (TerrainType (DirtT))
import Swarm.Game.Universe (Cosmo (..), SubworldName (DefaultRootSubworld))
import Swarm.Game.World (WorldFun (..), newWorld)
import Swarm.Language.Context qualified as Context
import Swarm.Language.Pipeline (ProcessedTerm)
Expand Down Expand Up @@ -73,7 +75,7 @@ circlerProgram =

-- | Initializes a robot with program prog at location loc facing north.
initRobot :: ProcessedTerm -> Location -> TRobot
initRobot prog loc = mkRobot () Nothing "" [] (Just loc) north defaultRobotDisplay (initMachine prog Context.empty emptyStore) [] [] False False 0
initRobot prog loc = mkRobot () Nothing "" [] (Just $ Cosmo DefaultRootSubworld loc) north defaultRobotDisplay (initMachine prog Context.empty emptyStore) [] [] False False 0

-- | Creates a GameState with numRobot copies of robot on a blank map, aligned
-- in a row starting at (0,0) and spreading east.
Expand All @@ -85,7 +87,7 @@ mkGameState robotMaker numRobots = do
(mapM addTRobot robots)
( (initAppState ^. gameState)
& creativeMode .~ True
& world .~ newWorld (WF $ const (fromEnum DirtT, Nothing))
& multiWorld .~ M.singleton DefaultRootSubworld (newWorld (WF $ const (fromEnum DirtT, Nothing)))
)

-- | Runs numGameTicks ticks of the game.
Expand Down
3 changes: 2 additions & 1 deletion swarm.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ benchmark benchmark
mtl,
random,
swarm,
text
text,
containers
default-language: Haskell2010
ghc-options: -threaded

0 comments on commit 9a4ffd5

Please sign in to comment.