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A6HGJMBMFRPQCVE5OLKWJQC NMV4GGIJSHARTJRLUHX7GTDBOKRYIPFGFAA77F2CAL4HAOIKAMDQC O7B34AE2RCSSUKPDKL6VRLOAGH3OYXD6VAI6C6KHZMA7RWUMN2MQC 6TR3H656MQ3WM3RFWZRHWATU4G5MPRR2CEVM3BAVONWMRMVNVQ4QC NQEZG66FQWQQOOYXN2GK7MHIQH25QBBNKE37GGDJBCHCSKWJZABQC F6CAOERUHO3PYEPIT6VBNZPRALQPCAAZDTQFGFFVRLIVSECETU4AC DPKNMYAABC2UGZ2VAU2GKRDWZSRHFG24VOJ3X57MMPFY76YXJWHAC } (verse 19 :: Verse (Maybe Train))
, size = z, vtrack = generateTrack $ verse z, vtrain = set (Just Train { heading = I , movement = Nothing }) 0 $ verse z}wherez = 19generateTrack :: Verse (Maybe Track) -> Verse (Maybe Track)generateTrack = sets $ (, Just Track) <$> scanr (shift z 1) 0 (replicate 1 N <>replicate 1 H <>replicate 1 U <>replicate 1 M <>replicate 3 N <>replicate 3 M <>replicate 4 L <>replicate 4 I <>replicate 5 U <>replicate 1 H <>replicate 1 N <>replicate 9 H <>replicate 1 U <>replicate 3 H <>replicate 1 N <>replicate 3 M <>replicate 9 L <>replicate 2 M <>replicate 2 N <>replicate 2 H <>replicate 2 U <>replicate 7 I )-- Data
f s ns a = a
f s i ns a@(Just Train { heading = h })-- go if track ahead| Nothing <- get (vtrack s) i = stop <$> a| Just Track <- trackns h = go <$> a| l <- back h , Just Track <- trackns l = go . steer l <$> a| r <- forw h , Just Track <- trackns r = go . steer r <$> a| otherwise = stop <$> awheretrackns :: Dir -> Maybe Tracktrackns dir = get (vtrack s) $ shift (size s) 1 dir if s i ns a = asteer :: Dir -> Train -> Trainsteer dir t = t { heading = dir }go :: Train -> Traingo t = t { movement = Just $ heading t }
| KeyPress 'H' <- e = Right (s { center = shift v 1 H $ center s } , v)| KeyPress 'J' <- e = Right (s { center = shift v 1 N $ center s } , v)| KeyPress 'K' <- e = Right (s { center = shift v 1 I $ center s } , v)| KeyPress 'L' <- e = Right (s { center = shift v 1 L $ center s } , v)| KeyPress 'h' <- e = Right (s { focus = shift v 1 H $ focus s } , v)| KeyPress 'j' <- e = Right (s { focus = shift v 1 N $ focus s } , v)| KeyPress 'k' <- e = Right (s { focus = shift v 1 I $ focus s } , v)| KeyPress 'l' <- e = Right (s { focus = shift v 1 L $ focus s } , v)| KeyPress 'p' <- e = Right (s { play = not $ play s } , v)| KeyPress '.' <- e = Right (s { play = False } , v')| KeyPress 'q' <- e , Nothing <- get v (focus s) = Right (s , set (Just $ Train { movement = Nothing }) (focus s) v')| KeyPress 'q' <- e = Right (s , set Nothing (focus s) v')| play s , Tick <- e , mod (time s) (div (fromInteger $ eFPS g) 2) == 0 = Right (s { time = time s + 1 } , v')| otherwise = Right (s , v)where
| KeyPress 'H' <- e = Right s { center = shift r 1 H $ center s }| KeyPress 'J' <- e = Right s { center = shift r 1 N $ center s }| KeyPress 'K' <- e = Right s { center = shift r 1 I $ center s }| KeyPress 'L' <- e = Right s { center = shift r 1 L $ center s }| KeyPress 'h' <- e = Right s { focus = shift r 1 H $ focus s }| KeyPress 'j' <- e = Right s { focus = shift r 1 N $ focus s }| KeyPress 'k' <- e = Right s { focus = shift r 1 I $ focus s }| KeyPress 'l' <- e = Right s { focus = shift r 1 L $ focus s }| KeyPress 't' <- e , Nothing <- get (vtrack s) (focus s) = Right s { vtrack = set (Just Track) (focus s) $ vtrack s }| KeyPress 't' <- e = Right s { vtrack = set Nothing (focus s) $ vtrack s }
v' = sim mempty s v
| KeyPress 'T' <- e , Nothing <- get (vtrain s) (focus s) = Right s { vtrain = set (Just $ Train { heading = I , movement = Nothing }) (focus s) $ vtrain s }| KeyPress 'T' <- e = Right s { vtrain = set Nothing (focus s) $ vtrain s }| KeyPress 'g' <- e = Right s { vtrain = upd (fmap (\t -> t { heading = I })) (focus s) $ vtrain s }
draw :: GEnv -> (State,Verse (Maybe Train)) -> Planedraw e (s,v) = hex
| KeyPress 'p' <- e = Right s { play = not $ play s }| KeyPress '.' <- e = Right s' { play = False }| Tick <- e , play s , mod (time s) (div (fromInteger $ eFPS g) 2) == 0 = Right s'| Tick <- e , play s = Right s { time = time s + 1 }| otherwise = Right s
io 190State { center = r , rand = r }(set (Hex { look = pick r total , seed = rs , parent = Nothing , i = 1 }) 0 (verse size))
io 190 (State { center = r , rand = r } , set (Hex { look = pick r total , seed = rs , parent = Nothing , i = 1 }) 0 (verse 9))
| KeyPress 'r' <- e , r : rs <- seed $ get v 0 = Right (s { rand = r },set (Hex { look = pick r total , seed = rs , parent = Nothing , i = 1 }) 0 (verse size))| KeyPress 'h' <- e = Right (s { center = shift v 1 H $ center s },v)| KeyPress 'j' <- e = Right (s { center = shift v 1 N $ center s },v)| KeyPress 'k' <- e = Right (s { center = shift v 1 I $ center s },v)| KeyPress 'l' <- e = Right (s { center = shift v 1 L $ center s },v)
| KeyPress 'r' <- e , r : rs <- seed $ get v 0 = Right (s { rand = r },set (Hex { look = pick r total , seed = rs , parent = Nothing , i = 1 }) 0 (verse z))| KeyPress 'h' <- e = Right (s { center = shift z 1 H $ center s },v)| KeyPress 'j' <- e = Right (s { center = shift z 1 N $ center s },v)| KeyPress 'k' <- e = Right (s { center = shift z 1 I $ center s },v)| KeyPress 'l' <- e = Right (s { center = shift z 1 L $ center s },v)
hex = cellsPlane (succ $ 2 * size * 2) (succ $ 2 * size) [ write (x,y) | x <- [-size..size] , y <- [-size..size] , abs (x + y) <= size ]
hex = cellsPlane (succ $ 2 * r * 2) (succ $ 2 * r) [ write (x,y) | x <- [-r..r] , y <- [-r..r] , abs (x + y) <= r ]
| KeyPress 'H' <- e = Right (s { center = shift v 1 H $ center s } , v)| KeyPress 'J' <- e = Right (s { center = shift v 1 N $ center s } , v)| KeyPress 'K' <- e = Right (s { center = shift v 1 I $ center s } , v)| KeyPress 'L' <- e = Right (s { center = shift v 1 L $ center s } , v)| KeyPress 'h' <- e = Right (s { focus = shift v 1 H $ focus s } , v)| KeyPress 'j' <- e = Right (s { focus = shift v 1 N $ focus s } , v)| KeyPress 'k' <- e = Right (s { focus = shift v 1 I $ focus s } , v)| KeyPress 'l' <- e = Right (s { focus = shift v 1 L $ focus s } , v)
| KeyPress 'H' <- e = Right (s { center = shift r 1 H $ center s } , v)| KeyPress 'J' <- e = Right (s { center = shift r 1 N $ center s } , v)| KeyPress 'K' <- e = Right (s { center = shift r 1 I $ center s } , v)| KeyPress 'L' <- e = Right (s { center = shift r 1 L $ center s } , v)| KeyPress 'h' <- e = Right (s { focus = shift r 1 H $ focus s } , v)| KeyPress 'j' <- e = Right (s { focus = shift r 1 N $ focus s } , v)| KeyPress 'k' <- e = Right (s { focus = shift r 1 I $ focus s } , v)| KeyPress 'l' <- e = Right (s { focus = shift r 1 L $ focus s } , v)
io 20State { rand = r , center = 0 , input = (Nothing , mempty) , mode = Full , play = False }(generate (verse 42) rs)
io 20 (State { rand = r , center = 0 , input = (Nothing , mempty) , mode = Full , play = False } , generate (verse 42) rs)
, (shift v 1 U 0 , Robot { name = "t0" , ops = Move <$> cycle [U,N,L] }), (shift v 2 U 0 , Robot { name = "t1" , ops = Move <$> cycle [N,L,U] }), (shift v 1 U $ shift v 1 H 0 , Robot { name = "t2" , ops = Move <$> cycle [L,U,N] })
, (shift r 1 U 0 , Robot { name = "t0" , ops = Move <$> cycle [U,N,L] }), (shift r 2 U 0 , Robot { name = "t1" , ops = Move <$> cycle [N,L,U] }), (shift r 1 U $ shift r 1 H 0 , Robot { name = "t2" , ops = Move <$> cycle [L,U,N] })
, (shift v 8 I 0 , Robot { name = "d0" , ops = Move <$> repeat N }), (shift v 2 I 0 , Robot { name = "d1" , ops = Move <$> repeat I })
, (shift r 8 I 0 , Robot { name = "d0" , ops = Move <$> repeat N }), (shift r 2 I 0 , Robot { name = "d1" , ops = Move <$> repeat I })
, (shift v 7 H $ shift v 1 I 0 , Robot { name = "L0" , ops = Move <$> repeat L }), (shift v 8 H $ shift v 1 I 0 , Robot { name = "L1" , ops = Move <$> repeat L }), (shift v 9 H $ shift v 1 I 0 , Robot { name = "L2" , ops = Move <$> repeat L })
, (shift r 7 H $ shift r 1 I 0 , Robot { name = "L0" , ops = Move <$> repeat L }), (shift r 8 H $ shift r 1 I 0 , Robot { name = "L1" , ops = Move <$> repeat L }), (shift r 9 H $ shift r 1 I 0 , Robot { name = "L2" , ops = Move <$> repeat L })
, (shift v 2 M 0 , Robot { name = "r0" , ops = Move <$> cycle [L,H] }), (shift v 2 M $ shift v 1 L 0 , Robot { name = "r1" , ops = Move <$> cycle [H,L] })
, (shift r 2 M 0 , Robot { name = "r0" , ops = Move <$> cycle [L,H] }), (shift r 2 M $ shift r 1 L 0 , Robot { name = "r1" , ops = Move <$> cycle [H,L] })
, (shift v 5 N $ shift v 1 H 0 , Robot { name = "m0" , ops = Move <$> repeat L }), (shift v 5 N $ shift v 1 L 0 , Robot { name = "m1" , ops = Move <$> repeat H }), (shift v 5 N 0 , Robot { name = "m2" , ops = Move <$> [I] })
, (shift r 5 N $ shift r 1 H 0 , Robot { name = "m0" , ops = Move <$> repeat L }), (shift r 5 N $ shift r 1 L 0 , Robot { name = "m1" , ops = Move <$> repeat H }), (shift r 5 N 0 , Robot { name = "m2" , ops = Move <$> [I] })
, (shift v 7 L 0 , Robot { name = "p0" , ops = Move <$> repeat I }), (shift v 7 L $ shift v 3 I 0 , Robot { name = "p1" , ops = [] }), (shift v 7 L $ shift v 5 I 0 , Robot { name = "p2" , ops = [] }), (shift v 7 L $ shift v 7 I 0 , Robot { name = "p3" , ops = [] })
, (shift r 7 L 0 , Robot { name = "p0" , ops = Move <$> repeat I }), (shift r 7 L $ shift r 3 I 0 , Robot { name = "p1" , ops = [] }), (shift r 7 L $ shift r 5 I 0 , Robot { name = "p2" , ops = [] }), (shift r 7 L $ shift r 7 I 0 , Robot { name = "p3" , ops = [] })
, (shift v 6 H $ shift v 6 I 0 , Robot { name = "Tp" , ops = cycle [Move U , NoOp] }), (shift v 8 H $ shift v 9 I 0 , Robot { name = "Tp" , ops = cycle [Move N , NoOp] }), (shift v 9 H $ shift v 7 I 0 , Robot { name = "Tp" , ops = cycle [Move L , NoOp] }), (shift v 8 H $ shift v 8 I 0 , Robot { name = "T0" , ops = [] }), (shift v 8 H $ shift v 7 I 0 , Robot { name = "T1" , ops = [] }), (shift v 7 H $ shift v 7 I 0 , Robot { name = "T2" , ops = [] })
, (shift r 6 H $ shift r 6 I 0 , Robot { name = "Tp" , ops = cycle [Move U , NoOp] }), (shift r 8 H $ shift r 9 I 0 , Robot { name = "Tp" , ops = cycle [Move N , NoOp] }), (shift r 9 H $ shift r 7 I 0 , Robot { name = "Tp" , ops = cycle [Move L , NoOp] }), (shift r 8 H $ shift r 8 I 0 , Robot { name = "T0" , ops = [] }), (shift r 8 H $ shift r 7 I 0 , Robot { name = "T1" , ops = [] }), (shift r 7 H $ shift r 7 I 0 , Robot { name = "T2" , ops = [] })
| KeyPress 'H' <- e = Right (s { center = shift v 1 H $ center s } , v)| KeyPress 'J' <- e = Right (s { center = shift v 1 N $ center s } , v)| KeyPress 'K' <- e = Right (s { center = shift v 1 I $ center s } , v)| KeyPress 'L' <- e = Right (s { center = shift v 1 L $ center s } , v)
| KeyPress 'H' <- e = Right (s { center = shift r 1 H $ center s } , v)| KeyPress 'J' <- e = Right (s { center = shift r 1 N $ center s } , v)| KeyPress 'K' <- e = Right (s { center = shift r 1 I $ center s } , v)| KeyPress 'L' <- e = Right (s { center = shift r 1 L $ center s } , v)
go (args ? 1) 19State { play = True , algo = Waves , center = 0 , focus = 0 , rand = drop z r }(noise r $ verse z)
go (args ? 1) 19 (State { play = True , algo = Waves , center = 0 , focus = 0 , rand = drop z r } , noise r $ verse z)
| ATG.KeyPress 'H' <- e = Right (s { center = shift v 1 H $ center s } , v)| ATG.KeyPress 'J' <- e = Right (s { center = shift v 1 N $ center s } , v)| ATG.KeyPress 'K' <- e = Right (s { center = shift v 1 I $ center s } , v)| ATG.KeyPress 'L' <- e = Right (s { center = shift v 1 L $ center s } , v)| ATG.KeyPress 'h' <- e = Right (s { focus = shift v 1 H $ focus s } , v)| ATG.KeyPress 'j' <- e = Right (s { focus = shift v 1 N $ focus s } , v)| ATG.KeyPress 'k' <- e = Right (s { focus = shift v 1 I $ focus s } , v)| ATG.KeyPress 'l' <- e = Right (s { focus = shift v 1 L $ focus s } , v)
| ATG.KeyPress 'H' <- e = Right (s { center = shift r 1 H $ center s } , v)| ATG.KeyPress 'J' <- e = Right (s { center = shift r 1 N $ center s } , v)| ATG.KeyPress 'K' <- e = Right (s { center = shift r 1 I $ center s } , v)| ATG.KeyPress 'L' <- e = Right (s { center = shift r 1 L $ center s } , v)| ATG.KeyPress 'h' <- e = Right (s { focus = shift r 1 H $ focus s } , v)| ATG.KeyPress 'j' <- e = Right (s { focus = shift r 1 N $ focus s } , v)| ATG.KeyPress 'k' <- e = Right (s { focus = shift r 1 I $ focus s } , v)| ATG.KeyPress 'l' <- e = Right (s { focus = shift r 1 L $ focus s } , v)
hex = ATG.cellsPlane (succ $ 2 * size * 2) (succ $ 2 * size) [ write (x,y) | x <- [-size..size] , y <- [-size..size] , abs (x + y) <= size ]
hex = ATG.cellsPlane (succ $ 2 * r * 2) (succ $ 2 * r) [ write (x,y) | x <- [-r..r] , y <- [-r..r] , abs (x + y) <= r ]
| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'H') []) <- ev = Just (s { center = shift v 1 H $ center s } , v)| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'J') []) <- ev = Just (s { center = shift v 1 N $ center s } , v)| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'K') []) <- ev = Just (s { center = shift v 1 I $ center s } , v)| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'L') []) <- ev = Just (s { center = shift v 1 L $ center s } , v)| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'h') []) <- ev = Just (s { focus = shift v 1 H $ focus s } , v)| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'j') []) <- ev = Just (s { focus = shift v 1 N $ focus s } , v)| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'k') []) <- ev = Just (s { focus = shift v 1 I $ focus s } , v)| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'l') []) <- ev = Just (s { focus = shift v 1 L $ focus s } , v)
| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'H') []) <- ev = Just (s { center = shift r 1 H $ center s } , v)| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'J') []) <- ev = Just (s { center = shift r 1 N $ center s } , v)| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'K') []) <- ev = Just (s { center = shift r 1 I $ center s } , v)| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'L') []) <- ev = Just (s { center = shift r 1 L $ center s } , v)| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'h') []) <- ev = Just (s { focus = shift r 1 H $ focus s } , v)| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'j') []) <- ev = Just (s { focus = shift r 1 N $ focus s } , v)| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'k') []) <- ev = Just (s { focus = shift r 1 I $ focus s } , v)| Brick.VtyEvent (Vty.EvKey (Vty.KChar 'l') []) <- ev = Just (s { focus = shift r 1 L $ focus s } , v)
vtycellMap = M.fromList [ ((size - y , 2*(x+size)+y) , Vty.char attr ch) | x <- [-size..size] , y <- [-size..size] , abs (x+y) <= size , let (attr,ch) = vtycell x y ]
vtycellMap = M.fromList [ ((r - y , 2*(x+r)+y) , Vty.char attr ch) | x <- [-r..r] , y <- [-r..r] , abs (x+y) <= r , let (attr,ch) = vtycell x y ]
n = shift v mx L . shift v my I $ coordToIndex v (mod (x - div y size * size) (3*size) , mod y size)(mx,my) = indexToCoord v $ center s
n = shift r mx L . shift r my I $ coordToIndex r (mod (x - div y r * r) (3*r) , mod y r)(mx,my) = indexToCoord r $ center s
verse r = vwherev = Verse{ radius = r, nodes = V.generate (3 * r * r) (\i -> Node { ix = i , atom = void }), neighbours = U.generate (3 * r * r * 6) (\i -> shift v 1 (toEnum $ mod i 6) (div i 6))}
verse r = Verse{ radius = r, nodes = V.generate (3 * r * r) (\i -> Node { ix = i , atom = void }), neighbours = U.generate (3 * r * r * 6) (\i -> shift r 1 (toEnum $ mod i 6) (div i 6))}
shift :: Verse a -> Int -> Dir -> Int -> Intshift v n d i| L <- d = coordToIndex v $ f (mod (x + n) (r * 3) , y)| I <- d = coordToIndex v $ f (x , y + n)| U <- d = shift v n I . shift v n H $ i| H <- d = shift v (negate n) L i| N <- d = shift v (negate n) I i| M <- d = shift v (negate n) U i
shift :: Int -> Int -> Dir -> Int -> Intshift r n d i| L <- d = coordToIndex r $ f (mod (x + n) (r * 3) , y)| I <- d = coordToIndex r $ f (x , y + n)| U <- d = shift r n I . shift r n H $ i| H <- d = shift r (negate n) L i| N <- d = shift r (negate n) I i| M <- d = shift r (negate n) U i
class Atom a => Interface state a wherelogic :: GEnv -> (state,Verse a) -> Event -> Either () (state,Verse a)draw :: GEnv -> (state,Verse a) -> Plane
class Interface state wherelogic :: GEnv -> state -> Event -> Either () statedraw :: GEnv -> state -> Plane