- -- print $ pathsToEnemies ah layout agents
- -- print $ bestMove ah layout agents
- let a1 = doNRounds 22 layout agents
- putStrLn $ showWorld layout a1
- print a1
- let a2 = doRound layout a1
- putStrLn $ showWorld layout a2
- print a2
- let a3 = doRound layout a2
- putStrLn $ showWorld layout a3
- print a3
- let a4 = doRound layout a3
- putStrLn $ showWorld layout a4
- print a4
- let a5 = doRound layout a4
- putStrLn $ showWorld layout a5
- print a5
- let a6 = doRound layout a5
- putStrLn $ showWorld layout a6
- print a6
-
-
-showWorld layout agents = unlines rows
- where rows = map (showRow layout agents) [minRow..maxRow]
- minRow = fst $ S.findMin layout'
- maxRow = fst $ S.findMax layout'
- layout' = S.union layout $ S.fromList $ M.keys agents
-
-showRow layout agents row = map (\col -> showCell (row, col) layout agents) [minCol..maxCol]
- where minCol = minimum $ map snd $ S.toList layout'
- maxCol = maximum $ map snd $ S.toList layout'
- layout' = S.union layout $ S.fromList $ M.keys agents
-
-showCell c layout agents =
- if c `M.member` agents
- then if isElf a then 'E' else 'G'
- else if c `S.member` layout then '.' else '\x2593'
- where a = agents!c
+ -- print $ pathsToEnemies ah layout agents
+ -- print $ bestMove ah layout agents
+ -- let a1 = doRound layout agents
+ -- let a0 = doRound layout agents
+ -- putStrLn $ "1\n" ++ showWorld layout a0
+ -- print a0
+ -- let n = 35
+ -- let a1 = doNRounds n layout agents
+ -- putStrLn $ show n ++ "\n" ++ showWorld layout a1
+ -- print a1
+ -- let a2 = doRound layout a1
+ -- putStrLn $ show (n+1) ++ "\n" ++ showWorld layout a2
+ -- print a2
+ -- let a3 = doRound layout a2
+ -- putStrLn $ show (n+2) ++ "\n" ++ showWorld layout a3
+ -- print a3
+ -- let a4 = doRound layout a3
+ -- putStrLn $ show (n+3) ++ "\n" ++ showWorld layout a4
+ -- print a4
+ -- let a5 = doRound layout a4
+ -- putStrLn $ show (n+4) ++ "\n" ++ showWorld layout a5
+ -- print a5
+
+ -- let a6 = doRound layout a5
+ -- putStrLn $ "27\n" ++ showWorld layout a6
+ -- print a6
+ -- let a7 = doRound layout a6
+ -- putStrLn $ "28\n" ++ showWorld layout a7
+ -- print a7
+ -- let a8 = doNRounds 19 layout a7
+ -- putStrLn $ "47\n" ++ showWorld layout a8
+ -- print a8
+ -- let a9 = doRound layout a8
+ -- putStrLn $ "30\n" ++ showWorld layout a9
+ -- print a9
+ -- let aa = doRound layout a9
+ -- putStrLn $ "31\n" ++ showWorld layout aa
+ -- print aa
+ -- let ab = doRound layout aa
+ -- putStrLn $ "32\n" ++ showWorld layout ab
+ -- print ab
+ -- let ac = doRound layout ab
+ -- putStrLn $ "33\n" ++ showWorld layout ac
+ -- print ac
+ -- let ad = doRound layout ac
+ -- putStrLn $ "34\n" ++ showWorld layout ad
+ -- print ad
+ -- let ae = doRound layout ad
+ -- putStrLn $ "35\n" ++ showWorld layout ae
+ -- print ae
+
+
+part1 layout agents = scoreGame $ runGame layout agents 3
+
+part2 layout agents = runPart2 layout agents 4
+
+runPart2 layout agents elfPower =
+ if wonWithoutLoss game
+ then (scoreGame game, elfPower)
+ else runPart2 layout agents (elfPower + 1)
+ where game = runGame layout agents elfPower
+
+
+-- showWorld layout agents = unlines rows
+-- where rows = map (showRow layout agents) [minRow..maxRow]
+-- minRow = fst $ S.findMin layout'
+-- maxRow = fst $ S.findMax layout'
+-- layout' = S.union layout $ S.fromList $ M.keys agents
+
+-- showRow layout agents row = map (\col -> showCell (row, col) layout agents) [minCol..maxCol]
+-- where minCol = minimum $ map snd $ S.toList layout'
+-- maxCol = maximum $ map snd $ S.toList layout'
+-- layout' = S.union layout $ S.fromList $ M.keys agents
+
+-- showCell c layout agents =
+-- if c `M.member` agents
+-- then if isElf a then 'E' else 'G'
+-- else if c `S.member` layout then '.' else '\x2593'
+-- where a = agents!c