1 module Sim ( initSimSpace, testSim, physStep ) where
3 import Data.Vector ((!), (//))
4 import qualified Data.Vector as V
6 -- Simulation simSpace simW simH
7 data Simulation = Simulation (V.Vector ChunkData) Int Int deriving (Show)
11 | Wall deriving (Show)
13 data ChunkData = ChunkData ChunkType deriving (Show)
17 simGet (Simulation s w _) i = veccGet s w i
19 veccSet v w c i = v // [(i,c)]
20 simSet (Simulation s w h) c i = Simulation (veccSet s w c i) w h
22 initSimSpace x y = Simulation (V.replicate (y*x) (ChunkData Empty)) x y
24 testSim = simSet (initSimSpace 10 10) (ChunkData Water) 5
26 physStep sim@(Simulation _ w h) = _physStep 0 (initSimSpace w h) sim
27 _physStep i acc sim@(Simulation s w h) =
29 else _physStep (i+1) next sim
31 getChunkData (ChunkData c) = c
32 next = case getChunkData $ simGet sim i of
36 -- initGaussSeidel s =
38 -- w = length (s V.! 0)