refactor(desktop): collapse stroll-direction coin to a single draw

DRY: the roomier-side bias computed its probability two ways
(STROLL_TOWARD_ROOM and 1 - STROLL_TOWARD_ROOM). One draw XNOR'd against
the roomier side says the same thing more plainly.
This commit is contained in:
Brooklyn Nicholson 2026-06-29 22:53:38 -05:00
parent b7322f946d
commit 30cd39dc56

View file

@ -87,7 +87,8 @@ export function pickStrollTarget(ledge: Ledge, fromX: number, rng: Rng = Math.ra
const roomLeft = fromX - ledge.left
const roomRight = ledge.right - fromX
const goRight = roomRight >= roomLeft ? rng() < STROLL_TOWARD_ROOM : rng() < 1 - STROLL_TOWARD_ROOM
// Usually head to the roomier side; the long tail of the coin doubles back.
const goRight = (rng() < STROLL_TOWARD_ROOM) === (roomRight >= roomLeft)
const room = Math.max(0, goRight ? roomRight : roomLeft)
const minDist = Math.min(room, Math.max(span * STROLL_MIN_FRACTION, STROLL_MIN_PX))
const dist = minDist + rng() * Math.max(0, room - minDist)