diff options
author | tomsmeding <tom.smeding@gmail.com> | 2019-12-13 13:23:38 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2019-12-13 13:23:38 +0100 |
commit | b65af7e65e51a14b505bf3ae1b855dee1e9cd797 (patch) | |
tree | f2ef63e04746b41c8b0b5905103b9c0fd781151a | |
parent | 90429c61705b597aa4499e470d836efd6fa66143 (diff) |
See the gaaaaame
-rw-r--r-- | 2019/13.hs | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -1,9 +1,11 @@ {-# LANGUAGE MultiWayIf #-} module Main where +import Control.Concurrent import Data.List import qualified Data.Map.Strict as Map import Data.Maybe +import System.IO import Input import IntCode @@ -66,11 +68,20 @@ main = do Map.empty (blockBy 3 output) in length (filter (== 2) (Map.elems bd)) + putStr "\x1B[H\x1B[2J" + let program' = 2 : tail program loop ai mcont output = do let ai1 = foldl' (\ai' [a,b,c] -> processOutput (a, b, c) ai') ai (blockBy 3 output) - putStr "\x1B[H\x1B[2J" - putStr (unlines (printMap (aiScreen ai1))) + -- putStr "\x1B[1;1H\x1B[2J" + -- putStr (unlines (printMap (aiScreen ai1))) + flip mapM_ (blockBy 3 output) $ \[x,y,v] -> + if x /= -1 + then putStr ("\x1B[" ++ show (y + 1) ++ ";" ++ show (x + 1) ++ "H" ++ [".#+=O" !! fromIntegral v]) + else return () + putStrLn ("\x1B[24;1H" ++ show (aiScore ai1)) + hFlush stdout + threadDelay 2000 case mcont of Just cont -> case runContinue cont [provideInput ai1] of Left (cont', out) -> loop ai1 (Just cont') out |