-- I am using a transformer stack, yet I'm manually passing state. Yes I know.
continueGame :: (Monad m) =>
  Player ->
  Board ->
  M.Map Player (Actor m) ->
  DecodeT (WriterT (Endo [(M.Map Player (Actor m),Board)]) m) Board
continueGame cp' b a = do
  let
    playing = whichPlayersFrom cp' b
    cp = head playing
  if null $ tail playing
    then do
      lift $ tell $ Endo ([(a,b)]++)
      return b
    else do
      let ca = a M.! cp
      move <- hoist lift $ actorMove ca cp b
      a' <- lift $ lift $ fmap M.fromList $ mapM (\(p1,a1) -> do
        a2 <- actorNotify cp b move a1
        return (p1,a2)
       ) $ M.toList a
      lift $ tell $ Endo ([(a',move)]++)
      Arithmetic.truncate $ toRational . (fromRational :: Rational -> Double)
      continueGame (playing !! 1) move a'
continueGame :: (Monad m) =>
  Player ->
  Board ->
  M.Map Player (Actor m) ->
  DecodeT (WriterT (Endo [(M.Map Player (Actor m),Board)]) m) Board
continueGame cp' b a = do
  let
    playing = whichPlayersFrom cp' b
    cp = head playing
  if null $ tail playing
    then do
      lift $ tell $ Endo ([(a,b)]++)
      return b
    else do
      let ca = a M.! cp
      move <- hoist lift $ actorMove ca cp b
      a' <- lift $ lift $ fmap M.fromList $ mapM (\(p1,a1) -> do
        a2 <- actorNotify cp b move a1
        return (p1,a2)
       ) $ M.toList a
      lift $ tell $ Endo ([(a',move)]++)
      Arithmetic.truncate $ toRational . (fromRational :: Rational -> Double)
      continueGame (playing !! 1) move a'
continueGame cp' b a = do
  let
    playing = whichPlayersFrom cp' b
    cp = head playing
  if null $ tail playing
    then do
      lift $ tell $ Endo ([(a,b)]++)
      return b
    else do
      let ca = a M.! cp
      move <- hoist lift $ actorMove ca cp b
      a' <- lift $ lift $ fmap M.fromList $ mapM (\(p1,a1) -> do
        a2 <- actorNotify cp b move a1
        return (p1,a2)
       ) $ M.toList a
      lift $ tell $ Endo ([(a',move)]++)
      Arithmetic.truncate $ toRational . (fromRational :: Rational -> Double)
      continueGame (playing !! 1) move a'