diff --git a/src/Floorplan.hs b/src/Floorplan.hs index fde5e6c..9d1110e 100644 --- a/src/Floorplan.hs +++ b/src/Floorplan.hs @@ -170,11 +170,26 @@ buildInnerWalls rng input = then (col + 2, col + 2) else (col + 3,maxCol - 3) ) g1 - (nngen, nnmat) = doCross - g2 - (cr, cc) - (Boundaries coord (maxRow, maxCol)) - mat + (nngen, nnmat) = + if (cr - 2 > row && cr + 2 < maxRow) + && (cc - 2 > col && cc + 2 < maxCol) + then + doCross + g2 + (cr, cc) + (Boundaries coord (maxRow, maxCol)) + mat + else + let btups = (,) + <$> [fst (coord) .. maxRow] + <*> [snd (coord) .. maxCol] + in + ( g2 + , foldl + (\acc coords -> + M.setElem (replaceTile (acc M.! coords) Offi) coords acc + ) mat btups + ) doCross :: StdGen -> (Int, Int) @@ -212,13 +227,12 @@ buildInnerWalls rng input = btups = (,) <$> [fst (matmin b) .. fst (matmax b)] <*> [snd (matmin b) .. snd (matmax b)] - in if trace ("bs: " ++ show (boundSize b)) (boundSize b) >= 16 + in if boundSize b >= 16 then foldl (\(agen, amat) (cr, nb) -> doCross agen cr nb amat) (ngen, omat) (zip crosses nbs) - else trace - ("built cross at " ++ show coord ++ " within " ++ show b) + else (gen, omat) in (nngen, nnmat) | otherwise = (gn, mat)