eliminating toilet bug

This commit is contained in:
nek0 2018-10-14 23:18:41 +02:00
parent 5ec3be4429
commit c4c7541b71
3 changed files with 19 additions and 10 deletions

View file

@ -1,5 +1,7 @@
module Interior where
import qualified Affection as A
import Data.Matrix as M
import qualified Data.Map.Strict as Map
import Data.List as L
@ -100,11 +102,14 @@ placeInteriorIO imat imgmat irp graph =
newrp = rp ++ map (\(a, b, c) -> ReachPoint a b c)
(zip3 reachtypes reaches reachdirs)
in
if try > 10 || fromIntegral freeRoom < size appl
if try >= 10 || fromIntegral freeRoom <= size appl
then (g2, (mat, rp))
else
if (pr + nrows cmat - 1 > fst (matmax bnds) ||
pc + ncols cmat - 1 > snd (matmax bnds) ||
if pr + nrows cmat - 1 > fst (matmax bnds) ||
pc + ncols cmat - 1 > snd (matmax bnds)
then A.log A.Debug ("no cluster placed") $
placeCluster g2 bnds (try + 1) mat rp appl
else if
any (`notElem` clusterRoom appl)
(M.toList (M.submatrix
pr (pr + nrows cmat - 1)
@ -116,11 +121,15 @@ placeInteriorIO imat imgmat irp graph =
pr (pr + nrows cmat - 1)
pc (pc + ncols cmat - 1)
mat
))) ||
not (isReachable newmat [] (oldreaches ++ reaches) exits)
then placeCluster g2 bnds (try + 1) mat rp appl
else placeCluster
g2 bnds (try + 1) newmat newrp appl
))
then A.log A.Debug ("no cluster placed") $
placeCluster g2 bnds (try + 1) mat rp appl
else if
not (isReachable newmat [] (oldreaches ++ reaches) exits)
then A.log A.Debug ("no cluster placed") $
placeCluster g2 bnds (try + 1) mat rp appl
else A.log A.Debug ("placed cluster" ++ show appl) $
placeCluster g2 bnds (try + 1) newmat newrp appl
insertMat
:: Matrix (Maybe a)

View file

@ -27,7 +27,7 @@ data Cluster
| ClusterPlant2
| ClusterToilet
| ClusterWatercooler
deriving (Enum, Bounded)
deriving (Enum, Bounded, Show)
clusterMat :: Cluster -> Matrix (Maybe ImgId)
clusterMat ClusterBox1 =

View file

@ -171,7 +171,7 @@ naviGraph imgmat animBounds (V2 r c) =
map snd (filter
(\(V2 br bc, _) -> floor br == r + rr && floor bc == c + cc)
animBounds))
then V2 (r + rr) (c + cc): acc
then V2 (r + rr) (c + cc) : acc
else acc
)
[]