Commit 13915b67 authored by Nicolas Lenz's avatar Nicolas Lenz
Browse files

Use a glider as example

parent 0a80465b
...@@ -76,14 +76,16 @@ neighborsPos (Pos minY minX, Pos maxY maxX) pos = shiftPos pos <$> neighborShift ...@@ -76,14 +76,16 @@ neighborsPos (Pos minY minX, Pos maxY maxX) pos = shiftPos pos <$> neighborShift
neighborShifts :: [(Int, Int)] neighborShifts :: [(Int, Int)]
neighborShifts = [(-1, 1), (0, 1), (1, 1), (-1, 0), (1, 0), (-1, -1), (0, -1), (1, -1)] neighborShifts = [(-1, 1), (0, 1), (1, 1), (-1, 0), (1, 0), (-1, -1), (0, -1), (1, -1)]
-- A trivial test board: the oscillating blinker object -- A trivial test board with a glider
testBoard :: Board testBoard :: Board
testBoard = Board $ listArray (Pos 0 0, Pos 4 4) testBoard = Board $ listArray (Pos 0 0, Pos 6 6)
[ Dead, Dead, Dead, Dead, Dead [ Dead, Dead, Dead, Dead, Dead, Dead, Dead
, Dead, Dead, Dead, Dead, Dead , Dead, Dead, Dead, Dead, Dead, Dead, Dead
, Dead, Alive, Alive, Alive, Dead , Dead, Dead, Dead, Alive, Dead, Dead, Dead
, Dead, Dead, Dead, Dead, Dead , Dead, Dead, Dead, Dead, Alive, Dead, Dead
, Dead, Dead, Dead, Dead, Dead , Dead, Dead, Alive, Alive, Alive, Dead, Dead
, Dead, Dead, Dead, Dead, Dead, Dead, Dead
, Dead, Dead, Dead, Dead, Dead, Dead, Dead
] ]
main :: IO () main :: IO ()
...@@ -91,5 +93,5 @@ main = loop testBoard where ...@@ -91,5 +93,5 @@ main = loop testBoard where
loop board = do loop board = do
print board print board
putStrLn "" putStrLn ""
threadDelay 500000 threadDelay 200000
loop (transition conway board) loop (transition conway board)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment