Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Main where
- import Data.List
- main = writeFile "testoutput.txt" $ resize 22
- root = "summon MinecartCommandBlock ~ ~1 ~ {"
- slime = "Riding:{id:Slime,Size:-2,"
- cart = "Riding:{id:MinecartCommandBlock,"
- kill = "kill @e[type=MinecartCommandBlock,r=1]"
- c1 = ",Command:"
- c2 = "}"
- carts = cycle . reverse $ (slime ++ cart) : replicate 8 cart
- cartsN :: Int -> String
- cartsN n = concat . reverse . take n $ carts
- nines :: [a] -> [[a]]
- nines (a:b:c:d:e:f:g:h:i:xs) = [a,b,c,d,e,f,g,h,i] : nines xs
- nines xs = [xs]
- format :: [String] -> String
- format = concat . concat . intersperse [c2] . map reverse . nines . map ((c1++).(++c2)) . (kill:) . reverse
- compress :: [String] -> String
- compress [] = []
- compress xs = root ++ cartsN (length xs) ++ tail (format xs)
- data D = X|Y|Z
- posRel1 :: D -> Int -> String
- posRel1 X n = " ~"++show n++" ~-2 ~1"
- posRel1 Y n = " ~1 ~"++show (n-3)++" ~1"
- posRel1 Z n = " ~1 ~-2 ~"++show n
- posRel2 :: Int -> D -> Int -> String
- posRel2 m X n = " ~"++show n++" ~"++show (m-3)++" ~"++show m
- posRel2 m Y n = " ~"++show m++" ~"++show (n-3)++" ~"++show m
- posRel2 m Z n = " ~"++show m++" ~"++show (m-3)++" ~"++show n
- resize' :: D -> Int -> [String]
- resize' d n = (fromToWidth n (2*n) 1):steps n
- where
- fromToWidth a b w = "clone" ++ posRel1 d a ++ posRel2 (2*n) d (a+w-1) ++ posRel1 d b
- steps 1 = []
- steps 2 = [fromToWidth 2 3 1, fromToWidth 1 2 1]
- steps n = let n' = n-1 in fromToWidth n' (2*n') 2 : steps n'
- resize n = compress $ concatMap (flip resize' n) [Y,X,Z]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement