summaryrefslogtreecommitdiff
path: root/src/World
diff options
context:
space:
mode:
Diffstat (limited to 'src/World')
-rw-r--r--src/World/Lattice.hs23
-rw-r--r--src/World/Types.hs2
2 files changed, 24 insertions, 1 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..])
diff --git a/src/World/Types.hs b/src/World/Types.hs
index e9be991..78bd5af 100644
--- a/src/World/Types.hs
+++ b/src/World/Types.hs
@@ -104,6 +104,6 @@ instance (Combinable a) => Combinable (AgentPropList a) where
newtype Proposal a b c = Proposal (LatticePropList a b, AgentPropList c) deriving (Show, Eq)
instance (Combinable a, Combinable b, Combinable c) => Combinable (Proposal a b c) where
- identity = Proposal ([], [])
+ identity = Proposal (LatticePropList [], AgentPropList [])
combinable (Proposal (l, a)) (Proposal (l', a')) = (combinable l l') && (combinable a a')
combine (Proposal (l, a)) (Proposal (l', a')) = Proposal (combine l l', combine a a')