Implement randomness at the placement datatype level
This commit is contained in:
+10
-3
@@ -59,15 +59,22 @@ generateLevelFromRoomList gr w
|
||||
|
||||
-- the idea is to allow use of link coordinates for placements
|
||||
-- though the implementation is clunky
|
||||
-- this should PutNothing if there are no links available
|
||||
-- first it takes the random placements and derandomises them
|
||||
-- then it deals with link placement spots
|
||||
assignPlacementSpots :: StdGen -> Room -> (StdGen, [((Point2,Float),Placement)])
|
||||
assignPlacementSpots g rm = (g', map (_rmShift rm,) $ plmnts ++ plmnts')
|
||||
where
|
||||
(lnkplmnts, plmnts) = partition islnk (_rmPS rm)
|
||||
(randPlmnts, detPlmnts) = partition isRand (_rmPS rm)
|
||||
isRand RandomPlacement{} = True
|
||||
isRand _ = False
|
||||
(unrandPlmnts, g'') = runState (mapM _unRandomPlacement randPlmnts) g
|
||||
(lnkplmnts, plmnts) = partition islnk (unrandPlmnts ++ detPlmnts)
|
||||
islnk Placement{_placementSpot=PSLnk{}} = True
|
||||
islnk _ = False
|
||||
(shuffledLnks,g') = runState (shuffle $ _rmLinks rm) g
|
||||
(shuffledLnks,g') = runState (shuffle $ _rmLinks rm) g''
|
||||
(_,plmnts') = mapAccumR f (map (invShiftLinkBy $ _rmShift rm) shuffledLnks) lnkplmnts
|
||||
f lnks plmnt =
|
||||
f lnks plmnt =
|
||||
let (x:xs,ys) = partition (_psLinkTest $ _placementSpot plmnt) lnks
|
||||
thepair = _psLinkShift (_placementSpot plmnt) x
|
||||
in (xs++ys, updatePS (updatePSLnkUsing thepair) plmnt)
|
||||
|
||||
Reference in New Issue
Block a user