summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2019-12-13 13:23:38 +0100
committertomsmeding <tom.smeding@gmail.com>2019-12-13 13:23:38 +0100
commitb65af7e65e51a14b505bf3ae1b855dee1e9cd797 (patch)
treef2ef63e04746b41c8b0b5905103b9c0fd781151a
parent90429c61705b597aa4499e470d836efd6fa66143 (diff)
See the gaaaaame
-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