From bc6e8049aefbe29478e01e6cc4914162d45d7f79 Mon Sep 17 00:00:00 2001 From: "restyled-io[bot]" <32688539+restyled-io[bot]@users.noreply.github.com> Date: Sun, 4 Aug 2024 23:08:22 +0200 Subject: [PATCH] Restyled by fourmolu (#2097) Co-authored-by: Restyled.io --- src/swarm-engine/Swarm/Game/State.hs | 5 +++-- src/swarm-engine/Swarm/Game/State/Runtime.hs | 2 +- src/swarm-engine/Swarm/Game/State/Substate.hs | 2 +- src/swarm-engine/Swarm/Game/Step.hs | 21 +++++++++++-------- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/swarm-engine/Swarm/Game/State.hs b/src/swarm-engine/Swarm/Game/State.hs index b7fdf0312..d13e1452c 100644 --- a/src/swarm-engine/Swarm/Game/State.hs +++ b/src/swarm-engine/Swarm/Game/State.hs @@ -458,8 +458,9 @@ initGameState :: GameStateConfig -> GameState initGameState gsc = GameState { _creativeMode = False - , _temporal = initTemporalState (startPaused gsc) - & pauseOnCompletion .~ (if pauseOnObjectiveCompletion gsc then PauseOnAnyObjective else PauseOnWin) + , _temporal = + initTemporalState (startPaused gsc) + & pauseOnCompletion .~ (if pauseOnObjectiveCompletion gsc then PauseOnAnyObjective else PauseOnWin) , _winCondition = NoWinCondition , _winSolution = Nothing , _robotInfo = initRobots gsc diff --git a/src/swarm-engine/Swarm/Game/State/Runtime.hs b/src/swarm-engine/Swarm/Game/State/Runtime.hs index a7233777d..afd6dc7ab 100644 --- a/src/swarm-engine/Swarm/Game/State/Runtime.hs +++ b/src/swarm-engine/Swarm/Game/State/Runtime.hs @@ -1,5 +1,5 @@ -{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TemplateHaskell #-} -- | -- SPDX-License-Identifier: BSD-3-Clause diff --git a/src/swarm-engine/Swarm/Game/State/Substate.hs b/src/swarm-engine/Swarm/Game/State/Substate.hs index e36cebe4a..b942a9989 100644 --- a/src/swarm-engine/Swarm/Game/State/Substate.hs +++ b/src/swarm-engine/Swarm/Game/State/Substate.hs @@ -27,7 +27,7 @@ module Swarm.Game.State.Substate ( -- *** Temporal state TemporalState, - PauseOnObjective(..), + PauseOnObjective (..), initTemporalState, gameStep, runStatus, diff --git a/src/swarm-engine/Swarm/Game/Step.hs b/src/swarm-engine/Swarm/Game/Step.hs index 9a1e7c04b..ab3855643 100644 --- a/src/swarm-engine/Swarm/Game/Step.hs +++ b/src/swarm-engine/Swarm/Game/Step.hs @@ -28,9 +28,11 @@ import Control.Effect.Lens import Control.Effect.Lift import Control.Lens as Lens hiding (Const, distrib, from, parts, use, uses, view, (%=), (+=), (.=), (<+=), (<>=)) import Control.Monad (foldM, forM_, unless, when) +import Data.Foldable.Extra (notNull) import Data.Functor (void) import Data.IntMap qualified as IM import Data.IntSet qualified as IS +import Data.List (intercalate) import Data.Map qualified as M import Data.Maybe (fromMaybe) import Data.Sequence ((><)) @@ -75,8 +77,6 @@ import Swarm.Util.WindowedCounter qualified as WC import System.Clock (TimeSpec) import Witch (From (from)) import Prelude hiding (Applicative (..), lookup) -import Data.Foldable.Extra (notNull) -import Data.List (intercalate) -- | The main function to do one game tick. -- @@ -341,15 +341,18 @@ hypotheticalWinCheck em g ws oc = do _ -> return () queue <- messageInfo . announcementQueue Swarm.Util.<%= (>< Seq.fromList (map ObjectiveCompleted $ completionAnnouncementQueue finalAccumulator)) - + shouldPause <- use $ temporal . pauseOnCompletion -- TODO: remove this debug ouput - sendIO $ appendFile "log_win.txt" $ intercalate " \t" - [ show $ getTickNumber ts - , if newWinState == Ongoing then "ongoing" else "won" - , if (notNull queue) then "queued" else "empty" - , show shouldPause <> "\n" - ] + sendIO $ + appendFile "log_win.txt" $ + intercalate + " \t" + [ show $ getTickNumber ts + , if newWinState == Ongoing then "ongoing" else "won" + , if (notNull queue) then "queued" else "empty" + , show shouldPause <> "\n" + ] when (newWinState /= Ongoing || (notNull queue && shouldPause == PauseOnAnyObjective)) $ temporal . runStatus .= AutoPause