2018-11-13 03:16:02 +00:00
|
|
|
{-# LANGUAGE FlexibleInstances #-}
|
2018-03-03 16:03:17 +00:00
|
|
|
module Types.Interior where
|
|
|
|
|
2019-01-18 18:02:45 +00:00
|
|
|
import qualified Affection as A
|
|
|
|
|
2018-03-03 16:03:17 +00:00
|
|
|
import Data.Matrix as M
|
|
|
|
|
2018-04-02 14:29:35 +00:00
|
|
|
import Linear.V2
|
|
|
|
|
2019-01-18 18:02:45 +00:00
|
|
|
import System.Random (StdGen, randomR)
|
|
|
|
|
2018-03-03 16:03:17 +00:00
|
|
|
-- internal imports
|
|
|
|
|
|
|
|
import Types.Map
|
2018-04-14 16:43:05 +00:00
|
|
|
import Types.ReachPoint
|
2018-06-04 03:29:20 +00:00
|
|
|
import Types.ImgId
|
|
|
|
import Types.Direction
|
2018-03-03 16:03:17 +00:00
|
|
|
|
2019-01-18 18:02:45 +00:00
|
|
|
|
2018-03-03 16:03:17 +00:00
|
|
|
data Cluster
|
|
|
|
= ClusterBox1
|
2018-11-13 03:16:02 +00:00
|
|
|
| ClusterTableSW
|
|
|
|
| ClusterTableNW
|
|
|
|
| ClusterTableNE
|
|
|
|
| ClusterTableSE
|
2019-02-09 14:19:16 +00:00
|
|
|
| ClusterComputerTableSW
|
2018-03-31 21:22:10 +00:00
|
|
|
| ClusterCornerTable
|
2018-04-01 02:51:15 +00:00
|
|
|
| ClusterTableGroup
|
2018-07-21 04:43:26 +00:00
|
|
|
| ClusterCopier
|
2018-07-30 13:34:45 +00:00
|
|
|
| ClusterFlipchart
|
2018-11-13 03:16:02 +00:00
|
|
|
| ClusterConferenceTable
|
2018-07-31 11:30:17 +00:00
|
|
|
| ClusterPlant1
|
2018-07-31 20:59:25 +00:00
|
|
|
| ClusterPlant2
|
|
|
|
| ClusterToilet
|
2018-08-07 12:04:49 +00:00
|
|
|
| ClusterWatercooler
|
2019-01-10 17:31:36 +00:00
|
|
|
| ClusterVending
|
2019-01-18 18:02:45 +00:00
|
|
|
| ClusterCabinets
|
2018-10-14 21:18:41 +00:00
|
|
|
deriving (Enum, Bounded, Show)
|
2018-03-03 16:03:17 +00:00
|
|
|
|
2018-11-13 03:16:02 +00:00
|
|
|
-- row -> NS; col -> WE
|
2019-01-18 18:02:45 +00:00
|
|
|
clusterMatWithRPs :: Cluster -> (Int, Int) -> StdGen -> (Matrix (Maybe ImgId), [ReachPoint])
|
|
|
|
clusterMatWithRPs ClusterBox1 dim _ =
|
|
|
|
( M.fromLists
|
|
|
|
[ [Just ImgMiscBox1]
|
|
|
|
]
|
|
|
|
, clusterPoints ClusterBox1 dim
|
|
|
|
)
|
|
|
|
clusterMatWithRPs ClusterTableSW dim@(h, _) _ =
|
|
|
|
( M.fromLists $ replicate h
|
|
|
|
[Just ImgEmpty, Just ImgTableSW]
|
|
|
|
, clusterPoints ClusterTableSW dim
|
|
|
|
)
|
|
|
|
clusterMatWithRPs ClusterTableSE dim@(_, w) _ =
|
|
|
|
( M.fromLists $
|
|
|
|
[ replicate w (Just ImgTableSE)
|
|
|
|
, replicate w (Just ImgEmpty)
|
|
|
|
]
|
|
|
|
, clusterPoints ClusterTableSE dim
|
|
|
|
)
|
|
|
|
clusterMatWithRPs ClusterTableNE dim@(h, _) _ =
|
|
|
|
( M.fromLists $ replicate h
|
|
|
|
[Just ImgTableNE, Just ImgEmpty]
|
|
|
|
, clusterPoints ClusterTableNE dim
|
|
|
|
)
|
|
|
|
clusterMatWithRPs ClusterTableNW dim@(_, w) _ =
|
|
|
|
( M.fromLists $
|
|
|
|
[ replicate w (Just ImgEmpty)
|
|
|
|
, replicate w (Just ImgTableNW)
|
|
|
|
]
|
|
|
|
, clusterPoints ClusterTableNW dim
|
|
|
|
)
|
2019-02-09 14:19:16 +00:00
|
|
|
clusterMatWithRPs ClusterComputerTableSW dim _ =
|
|
|
|
( M.fromLists [
|
|
|
|
[Just ImgEmpty, Just ImgTableSW]
|
|
|
|
]
|
|
|
|
, clusterPoints ClusterComputerTableSW dim
|
|
|
|
)
|
2019-01-18 18:02:45 +00:00
|
|
|
clusterMatWithRPs ClusterCornerTable dim _ =
|
|
|
|
( M.fromLists
|
|
|
|
[ [Just ImgTableSE, Just ImgTableCorner]
|
|
|
|
, [Just ImgEmpty, Just ImgTableSW]
|
|
|
|
]
|
|
|
|
, clusterPoints ClusterCornerTable dim
|
2019-02-09 14:19:16 +00:00
|
|
|
)
|
2019-01-18 18:02:45 +00:00
|
|
|
clusterMatWithRPs ClusterTableGroup dim _ =
|
|
|
|
( M.fromLists
|
|
|
|
[ [ Just ImgEmpty, Just ImgTableSE, Just ImgTableCorner
|
|
|
|
, Just ImgEmpty, Just ImgTableSE, Just ImgTableCorner
|
|
|
|
]
|
|
|
|
, [ Just ImgEmpty, Just ImgEmpty, Just ImgTableSW
|
|
|
|
, Just ImgEmpty, Just ImgEmpty, Just ImgTableSW
|
|
|
|
]
|
|
|
|
, [ Just ImgEmpty, Just ImgEmpty, Just ImgEmpty
|
|
|
|
, Just ImgEmpty, Just ImgEmpty, Just ImgEmpty
|
|
|
|
]
|
|
|
|
, [ Nothing, Nothing, Nothing
|
|
|
|
, Just ImgEmpty, Just ImgTableSE, Just ImgTableCorner
|
|
|
|
]
|
|
|
|
, [ Nothing, Nothing, Nothing
|
|
|
|
, Just ImgEmpty, Just ImgEmpty, Just ImgTableSW
|
|
|
|
]
|
|
|
|
]
|
|
|
|
, clusterPoints ClusterTableGroup dim
|
|
|
|
)
|
|
|
|
clusterMatWithRPs ClusterCopier dim _ =
|
|
|
|
( M.fromLists
|
|
|
|
[ [ Just ImgEmptyNoWalk]
|
|
|
|
, [ Just ImgEmpty]
|
|
|
|
]
|
|
|
|
, clusterPoints ClusterCopier dim
|
|
|
|
)
|
|
|
|
clusterMatWithRPs ClusterFlipchart dim _ =
|
|
|
|
( M.fromLists
|
|
|
|
[ [ Just ImgMiscFlipchart]
|
|
|
|
, [ Just ImgEmpty]
|
|
|
|
]
|
|
|
|
, clusterPoints ClusterFlipchart dim
|
|
|
|
)
|
|
|
|
clusterMatWithRPs ClusterConferenceTable dim@(h, w) _ =
|
2018-11-13 10:41:36 +00:00
|
|
|
let mw = max 4 w
|
|
|
|
mh = max 4 h
|
2019-01-18 18:02:45 +00:00
|
|
|
in
|
|
|
|
( M.fromLists $
|
|
|
|
[ replicate mw (Just ImgEmpty)
|
|
|
|
, [ Just ImgEmpty, Just ImgTableC4] ++ replicate (mw-4) (Just ImgTableNW) ++
|
|
|
|
[ Just ImgTableC3, Just ImgEmpty ]
|
|
|
|
] ++
|
|
|
|
replicate (mh-4) ([ Just ImgEmpty, Just ImgTableSW] ++ replicate (mw-4) (Just ImgEmpty) ++
|
|
|
|
[ Just ImgTableNE, Just ImgEmpty ]) ++
|
|
|
|
[ [ Just ImgEmpty, Just ImgTableC1] ++ replicate (mw-4) (Just ImgTableSE) ++
|
|
|
|
[ Just ImgTableC2, Just ImgEmpty ]
|
|
|
|
, replicate mw (Just ImgEmpty)
|
|
|
|
]
|
|
|
|
, clusterPoints ClusterConferenceTable dim
|
|
|
|
)
|
|
|
|
clusterMatWithRPs ClusterPlant1 dim _ =
|
|
|
|
( M.fromLists
|
|
|
|
[ [ Just ImgMiscPlant1 ] ]
|
|
|
|
, clusterPoints ClusterPlant1 dim
|
|
|
|
)
|
|
|
|
clusterMatWithRPs ClusterPlant2 dim _ =
|
|
|
|
( M.fromLists
|
|
|
|
[ [ Just ImgMiscPlant2 ] ]
|
|
|
|
, clusterPoints ClusterPlant2 dim
|
|
|
|
)
|
|
|
|
clusterMatWithRPs ClusterToilet dim _ =
|
|
|
|
( M.fromLists
|
|
|
|
[ [ Just ImgEmpty, Just ImgEmptyNoWalk] ]
|
|
|
|
, clusterPoints ClusterToilet dim
|
|
|
|
)
|
|
|
|
clusterMatWithRPs ClusterWatercooler dim _ =
|
|
|
|
( M.fromLists
|
|
|
|
[ [ Just ImgMiscWatercooler ]
|
|
|
|
, [ Just ImgEmpty ]
|
|
|
|
]
|
|
|
|
, clusterPoints ClusterWatercooler dim
|
|
|
|
)
|
|
|
|
clusterMatWithRPs ClusterVending dim _ =
|
|
|
|
( M.fromLists
|
|
|
|
[ [ Just ImgMiscVending ]
|
|
|
|
, [ Just ImgEmpty ]
|
|
|
|
]
|
|
|
|
, clusterPoints ClusterVending dim
|
|
|
|
)
|
2019-02-09 14:19:16 +00:00
|
|
|
clusterMatWithRPs ClusterCabinets (h, w) g =
|
2019-01-18 18:02:45 +00:00
|
|
|
let iw = max 2 w
|
|
|
|
ih = max 2 h
|
|
|
|
rw = min 5 iw
|
|
|
|
rh = min 5 ih
|
|
|
|
selses =
|
|
|
|
[ ImgCabinetCoffeeSE
|
|
|
|
, ImgCabinetSinkSE
|
|
|
|
, ImgCabinetStoveSE
|
|
|
|
]
|
|
|
|
selsws =
|
|
|
|
[ ImgCabinetCoffeeSW
|
|
|
|
, ImgCabinetSinkSW
|
|
|
|
, ImgCabinetStoveSW
|
|
|
|
]
|
|
|
|
(g1, ses, seps) = foldl
|
|
|
|
(\(gen, lsi, lsr) a ->
|
|
|
|
let (switch, gf1) = randomR (1, 3) gen :: (Int, StdGen)
|
|
|
|
in if switch == 1
|
|
|
|
then
|
|
|
|
let (typ, gf2) = randomR (0, length selses - 1) gf1
|
|
|
|
img = selses !! typ
|
|
|
|
rp i
|
2019-02-09 00:23:38 +00:00
|
|
|
| i == ImgCabinetCoffeeSE = ReachPoint Drink (V2 2 a) NW 0
|
|
|
|
| i == ImgCabinetSinkSE = ReachPoint Drink (V2 2 a) NW 0
|
|
|
|
| i == ImgCabinetStoveSE = ReachPoint Eat (V2 2 a) NW 0
|
2019-01-18 18:02:45 +00:00
|
|
|
in (gf2, Just img : lsi, rp img : lsr)
|
|
|
|
else
|
|
|
|
(gf1, Just ImgCabinetSE : lsi, lsr)
|
|
|
|
)
|
|
|
|
(g, [], [])
|
|
|
|
(reverse [1 .. rw - 1])
|
|
|
|
(g2, sws, swps) = foldl
|
|
|
|
(\(gen, lsi, lsr) a ->
|
|
|
|
let (switch, gf1) = randomR (1, 3) gen :: (Int, StdGen)
|
|
|
|
in if switch == 1
|
|
|
|
then
|
|
|
|
let (typ, gf2) = randomR (0, length selsws - 1) gf1
|
|
|
|
img = selsws !! typ
|
|
|
|
rp i
|
2019-02-09 00:23:38 +00:00
|
|
|
| i == ImgCabinetCoffeeSW = ReachPoint Drink (V2 a (rw - 1)) NE 0
|
|
|
|
| i == ImgCabinetSinkSW = ReachPoint Drink (V2 a (rw - 1)) NE 0
|
|
|
|
| i == ImgCabinetStoveSW = ReachPoint Eat (V2 a (rw - 1)) NE 0
|
2019-01-18 18:02:45 +00:00
|
|
|
in (gf2, Just img : lsi, rp img : lsr)
|
|
|
|
else
|
|
|
|
(gf1, Just ImgCabinetSW : lsi, lsr)
|
|
|
|
)
|
|
|
|
(g1, [], [])
|
|
|
|
(reverse [1 .. rh - 1])
|
|
|
|
outmat =
|
|
|
|
(M.fromLists [ses] M.<|> M.fromLists [[ Just ImgCabinetCorner ]])
|
|
|
|
M.<->
|
|
|
|
(M.fromList (rh - 1) (rw - 1) (repeat $ Just ImgEmpty)
|
|
|
|
M.<|>
|
|
|
|
M.fromLists (map (\a -> [a]) sws)
|
|
|
|
)
|
|
|
|
in (outmat, (seps ++ swps))
|
2018-03-03 16:03:17 +00:00
|
|
|
|
2018-07-31 11:30:17 +00:00
|
|
|
clusterRoom :: Cluster -> [TileState]
|
|
|
|
clusterRoom ClusterBox1 = [Offi]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterRoom ClusterTableSW = [Offi]
|
|
|
|
clusterRoom ClusterTableNW = [Offi]
|
|
|
|
clusterRoom ClusterTableNE = [Offi]
|
|
|
|
clusterRoom ClusterTableSE = [Offi]
|
2019-02-09 14:19:16 +00:00
|
|
|
clusterRoom ClusterComputerTableSW = [Offi]
|
2018-07-31 11:30:17 +00:00
|
|
|
clusterRoom ClusterCornerTable = [Offi]
|
|
|
|
clusterRoom ClusterTableGroup = [Offi]
|
|
|
|
clusterRoom ClusterCopier = [Offi]
|
|
|
|
clusterRoom ClusterFlipchart = [Offi]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterRoom ClusterConferenceTable = [Offi]
|
2018-08-03 00:22:30 +00:00
|
|
|
clusterRoom ClusterPlant1 = [Offi]
|
|
|
|
clusterRoom ClusterPlant2 = [Offi]
|
2018-07-31 20:59:25 +00:00
|
|
|
clusterRoom ClusterToilet = [Toil]
|
2018-08-07 12:04:49 +00:00
|
|
|
clusterRoom ClusterWatercooler = [Kitc, Offi]
|
2019-01-10 17:31:36 +00:00
|
|
|
clusterRoom ClusterVending = [Kitc]
|
2019-01-18 18:02:45 +00:00
|
|
|
clusterRoom ClusterCabinets = [Kitc]
|
2018-03-03 16:03:17 +00:00
|
|
|
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints :: Cluster -> (Int, Int) -> [ReachPoint]
|
|
|
|
clusterPoints ClusterBox1 _ = []
|
|
|
|
clusterPoints ClusterTableNE (h, _) =
|
2019-02-09 00:23:38 +00:00
|
|
|
[ ReachPoint Table (V2 r 2) SW 0 | r <- [1..h] ]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterTableNW (_, w) =
|
2019-02-09 00:23:38 +00:00
|
|
|
[ ReachPoint Table (V2 1 c) SE 0 | c <- [1..w] ]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterTableSW (h, _) =
|
2019-02-09 00:23:38 +00:00
|
|
|
[ ReachPoint Table (V2 r 1) NE 0 | r <- [1..h] ]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterTableSE (_, w) =
|
2019-02-09 00:23:38 +00:00
|
|
|
[ ReachPoint Table (V2 2 c) NW 0 | c <- [1..w] ]
|
2019-02-09 14:19:16 +00:00
|
|
|
clusterPoints ClusterComputerTableSW _ =
|
|
|
|
[ ReachPoint Computer (V2 1 1) NE 0 ]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterCornerTable _ =
|
2019-02-09 00:23:38 +00:00
|
|
|
[ ReachPoint Computer (V2 2 1) N 0
|
2018-04-02 14:29:35 +00:00
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterTableGroup _ =
|
2019-02-09 00:23:38 +00:00
|
|
|
[ ReachPoint Computer (V2 2 2) N 0
|
|
|
|
, ReachPoint Computer (V2 2 5) N 0
|
|
|
|
, ReachPoint Computer (V2 5 5) N 0
|
2018-04-02 14:29:35 +00:00
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterCopier _ =
|
2019-02-09 00:23:38 +00:00
|
|
|
[ ReachPoint Copier (V2 2 1) NW 0
|
2018-07-21 04:43:26 +00:00
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterFlipchart _ =
|
2019-02-09 00:23:38 +00:00
|
|
|
[ ReachPoint Table (V2 2 1) NW 0
|
2018-07-30 13:34:45 +00:00
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterConferenceTable (h, w) =
|
2018-11-13 10:41:36 +00:00
|
|
|
let mw = max 4 w
|
|
|
|
mh = max 4 h
|
|
|
|
in
|
2019-02-09 00:23:38 +00:00
|
|
|
[ ReachPoint Table (V2 1 c) SE 0 | c <- [2..mw-1] ] ++
|
|
|
|
[ ReachPoint Table (V2 r 1) NE 0 | r <- [2..mh-1] ] ++
|
|
|
|
[ ReachPoint Table (V2 r mw) SW 0 | r <- [2..mh-1] ] ++
|
|
|
|
[ ReachPoint Table (V2 mh c) NW 0 | c <- [2..mw-1] ]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterToilet _ =
|
2019-02-09 00:23:38 +00:00
|
|
|
[ ReachPoint Toilet (V2 1 1) NE 0
|
2018-07-31 20:59:25 +00:00
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints ClusterWatercooler _ =
|
2019-02-09 00:23:38 +00:00
|
|
|
[ ReachPoint Drink (V2 2 1) NW 0
|
2018-08-07 12:04:49 +00:00
|
|
|
]
|
2019-01-10 17:31:36 +00:00
|
|
|
clusterPoints ClusterVending _ =
|
2019-02-09 00:23:38 +00:00
|
|
|
[ ReachPoint Eat (V2 2 1) NW 0
|
2019-01-10 17:31:36 +00:00
|
|
|
]
|
2018-11-13 03:16:02 +00:00
|
|
|
clusterPoints _ _ = []
|
2018-04-02 14:29:35 +00:00
|
|
|
|
2019-01-18 18:02:45 +00:00
|
|
|
instance Size (Cluster, (Int, Int), StdGen) where
|
|
|
|
size (c, dim, gen) =
|
|
|
|
let mat = fst $ clusterMatWithRPs c dim gen
|
2018-03-03 16:03:17 +00:00
|
|
|
in fromIntegral ((nrows mat) * (ncols mat))
|