mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-30 11:52:04 +00:00
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:
parent
b7322f946d
commit
30cd39dc56
1 changed files with 2 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue