summaryrefslogtreecommitdiff
path: root/src/World/Lattice.hs
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-12-04 20:10:18 -0600
committersanine <sanine.not@pm.me>2023-12-04 20:10:18 -0600
commit899ad0ed13d3e347e2818294f7ed9d8d4d468e94 (patch)
treeaa38d3b8c6980ca9e87f28be550573a3ba15b35e /src/World/Lattice.hs
parent749df3069669787d2c0a57fb9b9ad66a3605da19 (diff)
refactor: Lattice -> World.Lattice
Diffstat (limited to 'src/World/Lattice.hs')
-rw-r--r--src/World/Lattice.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/World/Lattice.hs b/src/World/Lattice.hs
new file mode 100644
index 0000000..257ea50
--- /dev/null
+++ b/src/World/Lattice.hs
@@ -0,0 +1,23 @@
+module World.Lattice
+ ( LatticeCell (..)
+ , Lattice
+ , LatticeRule
+ , updateLattice
+ ) where
+
+
+data LatticeCell a b = LatticeCell { kind :: a, flags :: b } deriving (Show, Eq)
+type Lattice a b = [[LatticeCell a b]]
+type LatticeRule a b = Lattice a b -> Int -> Int -> LatticeCell a b
+
+
+updateLattice :: (Enum a) => Lattice a b -> [LatticeRule a b] -> Lattice a b
+updateLattice lattice rules =
+ let
+ mapRow = \(row, y) -> map
+ (\((LatticeCell k _), x) ->
+ let rule = rules !! (fromEnum k)
+ in rule lattice x y
+ )
+ (zip row [0..])
+ in map mapRow (zip lattice [0..])