summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--2019/13.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/2019/13.hs b/2019/13.hs
index 29fb9b9..ca4444b 100644
--- a/2019/13.hs
+++ b/2019/13.hs
@@ -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