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STEP_MS","BAND","BAND_HALF","RATES","SWITCH_MS","EDGE","SLIP_RUN","SLIP_OVER","SLIP_COOLDOWN","REENTER_MS","SLIP_PENALTY","PERFECT_TOL","COMBO","DEEP_BONUS","CLIT","RUB","DUET_MOVES","MOVES","MOVE_PTS_MAX","BALLS_MIN_HER","BACK_MIN_HER","MOVE_LABEL","PLAY","SIZE","AVERAGE_SIZE","clampTo","v","k","r","RANGES","n","DEFAULT_SCULPT","himOf","p","h","tuneOf","her","sanitizePlay","him","sens","gain","t","big","small","tight","short","clamp01","thick","thin","fill","feelOf","clit","FEEL","g","grip","finishOf","b","FIT_LINE","fitOf","sz","list","m","summaryOf","moves","PLAY_MOVES","loves","likes","notInto","lines","fit","IDLE_FACTOR","IDLE_MIN_MS","STEADY","beatsIn","CAPTION","bandAt","pace","half","c","i","t0","c0","t1","c1","x","DuetGame","profile","kind","tu","his","flop","fx","pref","not","tooMuch","perfect","ev","halfLife","s","band","inBand","boost","last","iv","prev","frantic","run","on","dt","mv","d","rec","srt","r0","tempo","jitter","j","med","beats","sum","mean","sd","hw","a","f","q","steady","ease","o","scoreState","rhythm","stamina","score","titleFor","y","term","climaxPulse","ms","ph","HAPTICS"],"sources":["../../../../../../src/lib/sculpt/duet-game.ts"],"sourcesContent":["// PROTOTYPE (P2): the duet's game rules. Pure and deterministic: the same taps (and holds) at the same\n// times always give the same meters, outcome and score, at any frame rate (fixed 1/120 s steps).\n// No three, no DOM: the renderer reads the state (arousal per body, climax pulses), the HUD reads the\n// meters and the tempo hint, the server can recompute a score from the taps.\n//\n// The round: bring her meter to full before his runs out, within ROUND_MS.\n// - her meter rises while the tap tempo sits in her \"sweet spot\" band and the rhythm is steady; the band\n//   drifts over the round (slow tease, then faster, then a final push); too fast, too slow or erratic\n//   lets it fall. It forgives a human hand: a missed beat and the break around a move or a grind\n//   don't count against the rhythm, and a little unevenness doesn't slow her (STEADY; the score\n//   still counts it)\n// - his meter (he peaks at full; the HUD shows what is left as stamina) climbs with tempo, faster the\n//   harder he goes; hold (a deep slow grind) brings it back down and keeps her warm\n// - she reaches full first: climax (a win); he does first: an early finish; time runs out: no finish\n// Score = rhythm 60 / stamina 40.\n//\n// Action events (in state.events, for the renderer and the HUD):\n// - slip: a sudden tempo spike (a tap much faster than the rhythm, well over her band) pops him out;\n//   a small penalty on both meters. The next tap re-enters ('reenter'), unless it comes too soon\n//   ('miss': he slides off and has to wait again)\n// - deep: three perfect taps in a row (on her tempo, even spacing) earn a harder, deeper thrust\n// - switch: the position changes once, at SWITCH_MS\n// - edge: his meter crosses EDGE (near the end, the HUD warns)\n// - clit: a tap on her clit boosts her meter; best while he thrusts inside her band, with diminishing\n//   returns when spammed (a \"heat\" that cools over a couple of seconds)\n// - rub: a finger rubbing her clit (a tick every ~120 ms of movement): more than a tap per gesture,\n//   sharing the clit's heat, so spamming it fades too\n// - move: a special move from the action buttons (tease, clit rub, between, spank, balls deep, back\n//   door, pound). Each takes over for a moment (rhythm taps are ignored and the rhythm resumes after),\n//   has a cooldown, moves the meters, and scores points: x2 (\"perfect\") in its phase of the round\n//   (MOVES[k].window). Back door is hers to switch off (her pref 'off': never offered, refused), and\n//   too soon (under BACK_MIN_HER) or with her not into it, it is too much, too soon\n//\n// The profile (DuetProfile, optional): her Play settings (vulva-params.ts VulvaPlay) and his size.\n// Without one (or with the defaults) the round plays exactly as above. She never shows her settings\n// upfront: reaction events (loves, likes, dislike, deepspot, gspot, toomuch; captions in CAPTION) let\n// the player discover them, and summary() reveals them at the end.\n// - sensitivity: her gain (rhythm, combos, moves, clit) and how wide her sweet spot is\n// - pace: her band's tempo, slower or faster\n// - move preferences: loves / likes multiply a move's effect on her; one she's not into cools her a bit\n// - clit sensitivity: clit taps and rubs\n// - his size counts from the average man (AVERAGE_SIZE, the editor's): he plays neutral\n// - his length: from SIZE.deepCm Balls deep reaches her deep spot; shorter than average slips out less\n//   and has a stronger Tease and clit rub\n// - his girth: thicker than average fills her more per in-band thrust once she is warm, less before; a\n//   hard move on a thick one before she is warm is too much, too soon. Thinner warms her faster, less\n//   per thrust\n// - his balls: the finish (finishOf: spurts, rope thickness, slap) and a little stamina\n// - his curve up: past SIZE.gCurve, the G-spot angle on Balls deep, slow strokes and the grind\n// - her size preference and tightness scale his size effects. Skill still beats size: every size\n//   plays to a climax for a steady player (duet-profile.test.ts balance sims)\n\nimport { AVERAGE_SIZE, DEFAULT_SCULPT, RANGES, type SculptParams } from './params';\nimport { PLAY_MOVES, sanitizePlay, type VulvaPlay } from './vulva-params';\n\nexport const ROUND_MS = 45_000;\nexport const STEP_MS = 1000 / 120;\n\n/** Her sweet-spot tempo (taps per second) over the round: [round time ms, centre]. Linear between. */\nexport const BAND: readonly (readonly [number, number])[] = [\n\t[0, 1.2],\n\t[13_000, 1.3],\n\t[18_000, 2.0],\n\t[30_000, 2.2],\n\t[35_000, 3.0],\n\t[ROUND_MS, 3.2]\n];\n/** Half-width of the band, as a share of its centre. */\nexport const BAND_HALF = 0.35;\n\n/** Rates per second. */\nexport const RATES = {\n\t/** her rise at the band's centre with a perfectly steady rhythm */\n\therGain: 0.035,\n\t/** her fall when off the band (scaled by how far off) and when idle */\n\therLoss: 0.035,\n\therIdle: 0.02,\n\t/** while holding: she warms slowly, he cools down */\n\therHold: 0.008,\n\thisHold: -0.05,\n\t/** his climb: base + k * tempo^2 */\n\thisBase: 0.003,\n\thisK: 0.0028\n} as const;\n\nexport const SWITCH_MS = 20_000;\nexport const EDGE = 0.8;\n/** Frantic mashing slips him out: SLIP_RUN intervals in a row, each faster than SLIP_OVER x her band's\n *  top tempo. A quick or uneven tap never does. */\nexport const SLIP_RUN = 3;\nexport const SLIP_OVER = 2;\n/** No second slip within this long of re-entering. */\nexport const SLIP_COOLDOWN = 3000;\n/** After a slip the next tap re-enters only once he has settled this long; sooner is a miss. */\nexport const REENTER_MS = 150;\nexport const SLIP_PENALTY = { her: 0.05, his: 0.03 } as const;\n/** Perfect tap: within this share of her band's centre, and evenly spaced with the one before. */\nexport const PERFECT_TOL = 0.1;\nexport const COMBO = 3;\nexport const DEEP_BONUS = { her: 0.012, his: 0.006 } as const;\n/** A clit tap's boost: base, times IN_BAND while his tempo sits in her band, divided by 1 + heat. */\nexport const CLIT = { base: 0.022, inBand: 1.8, heatHalfMs: 1500 } as const;\n\n/** A finger rub on her clit, per tick: the boost (times CLIT.inBand while in her band) / (1 + heat),\n *  and the heat each tick adds. */\nexport const RUB = { base: 0.012, heat: 0.7, gestureGapMs: 600 } as const;\n\nexport type DuetMove = 'balls' | 'tease' | 'pound' | 'rub' | 'between' | 'spank' | 'back';\n/** Every move the game knows (the input log's allowlist), in the HUD's row order. */\nexport const DUET_MOVES: readonly DuetMove[] = [\n\t'tease',\n\t'rub',\n\t'between',\n\t'spank',\n\t'balls',\n\t'back',\n\t'pound'\n];\n/** The special moves: how long each takes over (ms), its cooldown (ms, from the press), its perfect\n *  window (round ms) and base points (x2 when perfect). Meter effects are in DuetGame.move(). */\nexport const MOVES: Record<\n\tDuetMove,\n\t{ ms: number; cooldown: number; window: readonly [number, number]; pts: number }\n> = {\n\t// tease early (her slow warm-up), balls deep mid round, pound in the final push\n\ttease: { ms: 1500, cooldown: 6000, window: [0, 13_000], pts: 3 },\n\tballs: { ms: 1000, cooldown: 7000, window: [13_000, 30_000], pts: 4 },\n\tpound: { ms: 900, cooldown: 8000, window: [30_000, ROUND_MS], pts: 5 },\n\t// a clit rub is best once she is in the first position's groove\n\trub: { ms: 1500, cooldown: 5000, window: [6000, SWITCH_MS], pts: 3 },\n\t// between her cheeks: his breather once the pace picks up after the switch\n\tbetween: { ms: 2000, cooldown: 9000, window: [SWITCH_MS, 35_000], pts: 2 },\n\t// a slap on a cheek: quick, any time she is warm, best mid round\n\tspank: { ms: 500, cooldown: 4000, window: [13_000, 30_000], pts: 2 },\n\t// out, a few strokes in her back door, and back in: the late round's big one\n\tback: { ms: 2600, cooldown: 12_000, window: [25_000, 40_000], pts: 6 }\n};\n/** Move points per round stop here (moves spice the score up, rhythm still decides it). */\nexport const MOVE_PTS_MAX = 25;\n/** Balls deep only lands once she is this warm; sooner it is \"Easy, tiger\". */\nexport const BALLS_MIN_HER = 0.5;\n/** Back door only lands once she is this warm; sooner it is too much, too soon. */\nexport const BACK_MIN_HER = 0.6;\n\n/** How hard the strokes are at a tempo, 0 (lazy) .. 1 (pounding): the renderer's force. */\nexport function forceOf(tempo: number) {\n\treturn Math.min(1, Math.max(0, (tempo - 1) / 2.5));\n}\n\n/** The quick moves' names, as the buttons and the end card show them. */\nexport const MOVE_LABEL: Record<DuetMove, string> = {\n\ttease: 'Tease',\n\trub: 'Clit rub',\n\tballs: 'Balls deep',\n\tpound: 'Pound',\n\tbetween: 'Between',\n\tspank: 'Spank',\n\tback: 'Back door'\n};\n\n/** His measurements the game reads (a SculptParams fits as is). */\nexport type DuetHim = Pick<SculptParams, 'length' | 'girth' | 'balls' | 'curveUp'>;\n/** Who plays: her Play settings (sanitized here, so old or partial params are fine) and his size.\n *  Missing her = the default settings; missing him = no size effects. */\nexport interface DuetProfile {\n\ther?: Partial<VulvaPlay> | null;\n\thim?: DuetHim | null;\n}\n\n/** Her Play settings as game numbers. Every default is a factor of 1. */\nexport const PLAY = {\n\t/** sensitivity 0..1: her gain x (1 + k (s - 0.5)), her band's half-width x (1 + k (s - 0.5)) */\n\tsensGain: 0.35,\n\tsensBand: 0.4,\n\t/** her band's tempo x */\n\tpace: { slow: 0.8, steady: 1, fast: 1.15 },\n\t/** x on a move's effect on her ('not': she cools by notDrop instead) */\n\tpref: { loves: 1.8, likes: 1.3, neutral: 1, not: 1, off: 0 },\n\tnotDrop: 0.03,\n\t/** x on clit taps, clit rubs and the Clit rub move */\n\tclit: { low: 0.6, normal: 1, high: 1.5 },\n\t/** her size preference: x on his length / girth bonuses, and on his smaller-size perks */\n\tsizeBig: { smaller: 0.5, any: 1, bigger: 1.5 },\n\tsizeSmall: { smaller: 1.5, any: 1, bigger: 0.5 },\n\t/** tightness: x on how full his girth feels (the bonus and the \"too much\") */\n\ttight: { tight: 1.4, normal: 1, relaxed: 0.6 }\n} as const;\n\n/** His size as game numbers (cm, like SculptParams). */\nexport const SIZE = {\n\t/** Balls deep reaches her deep spot from this length: her bonus, more the longer (to +6 cm) */\n\tdeepCm: 17,\n\tdeepBonus: 0.025,\n\t/** below shortCm, the average man's length (full at 8 cm): up to x (1 + shortPerk) on Tease and\n\t *  clit rubs, x (1 + shortSlip) on how frantic a slip has to be */\n\tshortCm: AVERAGE_SIZE.length,\n\tshortPerk: 0.35,\n\tshortSlip: 0.5,\n\t/** girth around girthRef, the average man's: thick (full at +5.5 cm) / thin (full at -4.5 cm) */\n\tgirthRef: AVERAGE_SIZE.girth,\n\t/** her meter below `warm` is the warm-up: thick gains x (1 - thickCold), thin x (1 + thinWarm);\n\t *  once warm thick gains x (1 + thickGain), thin x (1 - thinGain) */\n\twarm: 0.3,\n\tthickCold: 0.3,\n\tthickGain: 0.25,\n\tthinWarm: 0.25,\n\tthinGain: 0.15,\n\t/** a hard move (Balls deep, Pound) while her meter is under tooSoon + tooSoonK x fullness, on a\n\t *  thick one (fullness over tooMuchMin): too much, too soon, she cools by tooMuchDrop */\n\ttooSoon: 0.2,\n\ttooSoonK: 0.25,\n\ttooMuchMin: 0.3,\n\ttooMuchDrop: 0.03,\n\t/** curve up from gCurve: the G-spot angle, full at gCurve + 0.6. Balls deep x (1 + gBalls), slow\n\t *  in-band strokes x (1 + gSlow), the grind x (1 + gHold) */\n\tgCurve: 0.3,\n\tgBalls: 0.35,\n\tgSlow: 0.15,\n\tgHold: 0.5,\n\t/** bigger balls: his climb x (1 - ballsStamina x size) */\n\tballsStamina: 0.08\n} as const;\n\n/** The profile, worked out once per round. The default profile is all 1s and 0s. */\ninterface Tune {\n\ther: VulvaPlay;\n\t/** x on her gains */\n\tgain: number;\n\t/** her band: tempo x, half-width */\n\tpace: number;\n\thalf: number;\n\t/** x on clit taps / rubs (sensitivity included) */\n\tclit: number;\n\t/** x on Tease and clit rubs (short) */\n\tperk: number;\n\t/** x on how frantic a slip has to be */\n\tslip: number;\n\t/** x on her rhythm gain before / after the warm-up (girth) */\n\tcold: number;\n\tfull: number;\n\t/** her meter below which a hard move is too much (0 = never) */\n\ttooSoon: number;\n\t/** deep spot bonus for Balls deep (0 = out of reach) */\n\tdeep: number;\n\t/** G-spot angle 0..1 */\n\tg: number;\n\t/** x on his climb */\n\tstamina: number;\n}\n\nconst clampTo = (v: unknown, k: keyof typeof RANGES) => {\n\tconst r = RANGES[k],\n\t\tn = typeof v === 'number' && Number.isFinite(v) ? v : (DEFAULT_SCULPT[k] as number);\n\treturn Math.min(r.max, Math.max(r.min, n));\n};\n/** His dims, clamped to the editor's ranges (null when there is no him). */\nfunction himOf(p?: DuetProfile): DuetHim | null {\n\tconst h = p?.him;\n\tif (!h || typeof h !== 'object') return null;\n\treturn {\n\t\tlength: clampTo(h.length, 'length'),\n\t\tgirth: clampTo(h.girth, 'girth'),\n\t\tballs: clampTo(h.balls, 'balls'),\n\t\tcurveUp: clampTo(h.curveUp, 'curveUp')\n\t};\n}\n\nfunction tuneOf(p?: DuetProfile): Tune {\n\tconst her = sanitizePlay(p?.her),\n\t\thim = himOf(p),\n\t\tsens = her.sens - 0.5,\n\t\tgain = 1 + PLAY.sensGain * sens;\n\tconst t: Tune = {\n\t\ther,\n\t\tgain,\n\t\tpace: PLAY.pace[her.pace],\n\t\thalf: BAND_HALF * (1 + PLAY.sensBand * sens),\n\t\tclit: PLAY.clit[her.clitSens] * gain,\n\t\tperk: 1,\n\t\tslip: 1,\n\t\tcold: 1,\n\t\tfull: 1,\n\t\ttooSoon: 0,\n\t\tdeep: 0,\n\t\tg: 0,\n\t\tstamina: 1\n\t};\n\tif (!him) return t;\n\tconst big = PLAY.sizeBig[her.size],\n\t\tsmall = PLAY.sizeSmall[her.size],\n\t\ttight = PLAY.tight[her.tight];\n\tconst short = clamp01((SIZE.shortCm - him.length) / (SIZE.shortCm - 8)) * small;\n\tt.perk = 1 + SIZE.shortPerk * short;\n\tt.slip = 1 + SIZE.shortSlip * short;\n\tif (him.length >= SIZE.deepCm)\n\t\tt.deep = SIZE.deepBonus * (1 + clamp01((him.length - SIZE.deepCm) / 6)) * big;\n\tconst thick = clamp01((him.girth - SIZE.girthRef) / 5.5),\n\t\tthin = clamp01((SIZE.girthRef - him.girth) / 4.5);\n\t// how full he feels: tight makes the girth count for more, both ways\n\tconst fill = thick * tight;\n\tt.cold = Math.max(0.5, 1 - SIZE.thickCold * fill + SIZE.thinWarm * thin);\n\tt.full = 1 + SIZE.thickGain * fill * big - (SIZE.thinGain * thin) / tight;\n\tif (fill > SIZE.tooMuchMin) t.tooSoon = SIZE.tooSoon + SIZE.tooSoonK * fill * small;\n\tif (him.curveUp > SIZE.gCurve) t.g = 0.5 + 0.5 * clamp01((him.curveUp - SIZE.gCurve) / 0.6);\n\tt.stamina = 1 - SIZE.ballsStamina * clamp01((him.balls - 0.6) / 0.9);\n\treturn t;\n}\n\n/** How she looks to take him, for the renderer only (never scored). `grip`: -1 relaxed (a quick,\n *  easy slide) .. 1 tight on a thick one (a slow slide in, the entrance dragging with each stroke, a\n *  light squeeze at rest). Tight scales with his girth as the score's fullness does: a slim one\n *  still slides in easily. `clit`: her clit's twitch and swell, x0.6 / 1 / 1.5 by her clit\n *  sensitivity. */\nexport interface DuetFeel {\n\tgrip: number;\n\tclit: number;\n}\nexport function feelOf(p?: DuetProfile): DuetFeel {\n\tconst her = sanitizePlay(p?.her),\n\t\thim = himOf(p);\n\tconst clit = FEEL.clit[her.clitSens];\n\t// his girth, slim 0 .. average 0.45 .. thick 1 (no him: average)\n\tconst g = him ? clamp01((him.girth - SIZE.girthRef + 4.5) / 10) : 0.45;\n\tconst grip =\n\t\ther.tight === 'tight'\n\t\t\t? 0.1 + 0.9 * g * g\n\t\t\t: her.tight === 'relaxed'\n\t\t\t\t? -0.6 - 0.25 * (1 - g)\n\t\t\t\t: 0.35 * g * g - 0.05;\n\treturn { grip: Math.max(-1, Math.min(1, grip)), clit };\n}\nconst FEEL = { clit: { low: 0.6, normal: 1, high: 1.5 } as const };\n\n/** His finish for the renderer: spurt count (3..7), rope thickness x (0.8..1.2), how hard the balls\n *  slap (0..1). No him: today's 5 spurts, 1, 0.5. */\nexport interface DuetFinish {\n\tspurts: number;\n\trope: number;\n\tslap: number;\n}\nexport function finishOf(him?: DuetHim | null): DuetFinish {\n\tconst h = himOf({ him });\n\tif (!h) return { spurts: 5, rope: 1, slap: 0.5 };\n\tconst b = clamp01((h.balls - 0.6) / 0.9);\n\treturn { spurts: Math.round(3 + 4 * b), rope: 0.8 + 0.4 * b, slap: 0.25 + 0.75 * b };\n}\n\n/** How his size sat with her, for the end card (cheeky, never a put-down). */\nexport type DuetFit = 'great' | 'tight' | 'handful' | 'more';\nexport const FIT_LINE: Record<DuetFit, string> = {\n\tgreat: 'Great fit',\n\ttight: 'A tight squeeze',\n\thandful: 'A handful',\n\tmore: 'She wanted more'\n};\nexport function fitOf(p?: DuetProfile): DuetFit {\n\tconst him = himOf(p);\n\tif (!him) return 'great';\n\tconst her = sanitizePlay(p?.her);\n\t// -1 small .. 0 the average man (AVERAGE_SIZE) .. 1 big\n\tconst sz =\n\t\t0.5 * Math.max(-1, Math.min(1, (him.length - AVERAGE_SIZE.length) / 7)) +\n\t\t0.5 * Math.max(-1, Math.min(1, (him.girth - AVERAGE_SIZE.girth) / 4.5));\n\tif (sz > 0.3 && her.tight === 'tight') return 'tight';\n\tif (sz > 0.3 && her.size === 'smaller') return 'handful';\n\tif ((sz < 0 && her.size === 'bigger') || (sz < -0.3 && her.tight === 'relaxed')) return 'more';\n\treturn 'great';\n}\n\n/** The end card: her settings revealed, and the fit line. */\nexport interface DuetSummary {\n\t/** what she loves, then what she likes */\n\tfavourites: DuetMove[];\n\tnotInto: DuetMove[];\n\t/** ready-made lines: favourites, not her thing, pace, clit */\n\tlines: string[];\n\tfit: DuetFit;\n\tfitLine: string;\n}\nconst list = (m: DuetMove[]) =>\n\tm.length < 2\n\t\t? MOVE_LABEL[m[0]]\n\t\t: m\n\t\t\t\t.slice(0, -1)\n\t\t\t\t.map((k) => MOVE_LABEL[k])\n\t\t\t\t.join(', ') +\n\t\t\t' and ' +\n\t\t\tMOVE_LABEL[m[m.length - 1]];\nexport function summaryOf(p?: DuetProfile): DuetSummary {\n\tconst her = sanitizePlay(p?.her),\n\t\tmoves: DuetMove[] = [...PLAY_MOVES];\n\tconst loves = moves.filter((k) => her.prefs[k] === 'loves'),\n\t\tlikes = moves.filter((k) => her.prefs[k] === 'likes'),\n\t\tnotInto = moves.filter((k) => her.prefs[k] === 'not');\n\tconst lines: string[] = [];\n\tif (loves.length) lines.push(`She loves ${list(loves)}`);\n\tif (likes.length) lines.push(`She likes ${list(likes)}`);\n\tif (notInto.length)\n\t\tlines.push(`${list(notInto)} ${notInto.length > 1 ? 'are' : 'is'} not her thing`);\n\tlines.push(\n\t\ther.pace === 'slow'\n\t\t\t? 'She likes it slow'\n\t\t\t: her.pace === 'fast'\n\t\t\t\t? 'She likes it fast'\n\t\t\t\t: 'She likes a steady rhythm'\n\t);\n\tif (her.clitSens === 'high') lines.push('Her clit is extra sensitive');\n\telse if (her.clitSens === 'low') lines.push('Her clit takes patience');\n\tconst fit = fitOf(p);\n\treturn { favourites: [...loves, ...likes], notInto, lines, fit, fitLine: FIT_LINE[fit] };\n}\n\n/** A tap older than this many average intervals (and at least IDLE_MIN_MS) means the player stopped. */\nconst IDLE_FACTOR = 1.8;\nconst IDLE_MIN_MS = 900;\n\n/** Her meter forgives a human hand (the score doesn't): unevenness (the coefficient of variation of\n *  the intervals) up to `dead` is steady enough for her, past it her gain drops at `slope`. The score\n *  keeps the strict 1 - 1.8 x jitter. */\nexport const STEADY = { dead: 0.1, slope: 1.5 } as const;\n\n/** How many beats an interval `r` x the median one stands for: 2 or 3 when the beats between were\n *  missed (the tempo holds, the hand was just sloppy), else 1. */\nfunction beatsIn(r: number) {\n\treturn r >= 1.7 && r <= 2.35 ? 2 : r >= 2.6 && r <= 3.4 ? 3 : 1;\n}\n\nexport type DuetOutcome = 'climax' | 'early' | 'timeout';\nexport type DuetEventKind =\n\t| 'slip'\n\t| 'reenter'\n\t| 'miss'\n\t| 'deep'\n\t| 'switch'\n\t| 'edge'\n\t| 'clit'\n\t| 'rub'\n\t| 'move'\n\t| DuetReaction;\n/** Her reactions (they let the player discover her settings), each right after its 'move' event or\n *  with it in `move`. */\nexport type DuetReaction = 'loves' | 'likes' | 'dislike' | 'deepspot' | 'gspot' | 'toomuch';\nexport const CAPTION: Record<DuetReaction, string> = {\n\tloves: 'She loves that',\n\tlikes: 'She likes that',\n\tdislike: \"She's not into that\",\n\tdeepspot: 'Deep spot',\n\tgspot: 'G-spot angle',\n\ttoomuch: 'Too much, too soon'\n};\nexport interface DuetEvent {\n\tt: number;\n\tkind: DuetEventKind;\n\t/** 'move' (and a reaction to it): which, whether it was in its window (x2: never when she's not\n\t *  into it or it was too much), and whether it was too soon (balls deep before she is warm, pound\n\t *  before the final push) */\n\tmove?: DuetMove;\n\tperfect?: boolean;\n\tflop?: boolean;\n}\n\n/** A special move in progress: its meter changes spread over [at, until). */\ninterface ActiveMove {\n\tkind: DuetMove;\n\tat: number;\n\tuntil: number;\n\ther: number;\n\this: number;\n}\n\nexport interface DuetGameState {\n\t/** ms since the round started */\n\tt: number;\n\ther: number;\n\this: number;\n\t/** current tap tempo, taps per second (0 = stopped) */\n\ttempo: number;\n\t/** 0 steady .. 1 erratic (coefficient of variation of the last intervals) */\n\tjitter: number;\n\t/** where the tempo sits against her band: -1 far too slow .. 0 centred .. 1 far too fast */\n\toffBand: number;\n\tholding: boolean;\n\t/** set once, when the round ends */\n\toutcome: DuetOutcome | null;\n\tendT: number | null;\n\t/** accumulated rhythm quality over active time */\n\trhythmSum: number;\n\tactiveMs: number;\n\t/** slipped out, waiting for a re-entry tap */\n\tout: boolean;\n\toutAt: number | null;\n\t/** perfect taps in a row */\n\tcombo: number;\n\t/** 0 first position, 1 after the switch */\n\tpose: 0 | 1;\n\t/** his meter is past EDGE */\n\tedge: boolean;\n\t/** the special move in progress (null when none) */\n\tmove: DuetMove | null;\n\t/** points from special moves (added to the score) */\n\tmovePts: number;\n\tevents: DuetEvent[];\n}\n\n/** Her band at round time t; `pace` x the tempo and `half` the half-width (DuetGame.band applies her\n *  profile). */\nexport function bandAt(\n\tt: number,\n\tpace = 1,\n\thalf: number = BAND_HALF\n): { centre: number; lo: number; hi: number } {\n\tlet c = BAND[BAND.length - 1][1];\n\tfor (let i = 0; i < BAND.length - 1; i++) {\n\t\tconst [t0, c0] = BAND[i],\n\t\t\t[t1, c1] = BAND[i + 1];\n\t\tif (t <= t1) {\n\t\t\tc = c0 + ((c1 - c0) * Math.max(0, t - t0)) / (t1 - t0);\n\t\t\tbreak;\n\t\t}\n\t}\n\tc *= pace;\n\treturn { centre: c, lo: c * (1 - half), hi: c * (1 + half) };\n}\n\nconst clamp01 = (x: number) => Math.min(1, Math.max(0, x));\n\nexport class DuetGame {\n\tprivate readonly tune: Tune;\n\t/** His finish for the renderer (finishOf). */\n\treadonly finish: DuetFinish;\n\n\tconstructor(readonly profile: DuetProfile = {}) {\n\t\tthis.tune = tuneOf(profile);\n\t\tthis.finish = finishOf(profile.him);\n\t}\n\n\t/** An exact copy, carrying on bit for bit as this one would (a replay's checkpoint). Every field\n\t *  is plain data; the profile, its tuning and his finish are never written, so they are shared. */\n\tclone(): DuetGame {\n\t\tconst g = Object.create(DuetGame.prototype) as DuetGame;\n\t\tfor (const [k, v] of Object.entries(this))\n\t\t\t(g as unknown as Record<string, unknown>)[k] =\n\t\t\t\tk === 'tune' || k === 'finish' || k === 'profile' ? v : structuredClone(v);\n\t\treturn g;\n\t}\n\n\t/** Her band at round time t, with her pace and sensitivity (the HUD's tempo hint). */\n\tband(t: number) {\n\t\treturn bandAt(t, this.tune.pace, this.tune.half);\n\t}\n\n\t/** Her settings and the fit, revealed (the end card). */\n\tsummary(): DuetSummary {\n\t\treturn summaryOf(this.profile);\n\t}\n\n\treadonly state: DuetGameState = {\n\t\tt: 0,\n\t\ther: 0,\n\t\this: 0,\n\t\ttempo: 0,\n\t\tjitter: 0,\n\t\toffBand: 0,\n\t\tholding: false,\n\t\toutcome: null,\n\t\tendT: null,\n\t\trhythmSum: 0,\n\t\tactiveMs: 0,\n\t\tout: false,\n\t\toutAt: null,\n\t\tcombo: 0,\n\t\tpose: 0,\n\t\tedge: false,\n\t\tmove: null,\n\t\tmovePts: 0,\n\t\tevents: []\n\t};\n\tprivate taps: number[] = [];\n\t/** the last 8 taps (step's tempo window), their intervals, the intervals sorted */\n\tprivate rec = new Float64Array(8);\n\tprivate iv = new Float64Array(7);\n\tprivate srt = new Float64Array(7);\n\t/** where the rhythm last broke off (a move or a grind ended): the interval across it doesn't count */\n\tprivate seam = -Infinity;\n\tprivate holds: { at: number; on: boolean }[] = [];\n\tprivate hold = false;\n\tprivate n = 0;\n\tprivate lastIn = -Infinity;\n\tprivate heat = 0;\n\tprivate heatT = 0;\n\tprivate lastClit = -Infinity;\n\tprivate lastRub = -Infinity;\n\tprivate active: ActiveMove | null = null;\n\tprivate ready: Record<DuetMove, number> = {\n\t\tballs: 0,\n\t\ttease: 0,\n\t\tpound: 0,\n\t\trub: 0,\n\t\tbetween: 0,\n\t\tspank: 0,\n\t\tback: 0\n\t};\n\n\t/** ms left on a move's cooldown at round time t (0 = ready). */\n\tcooldown(kind: DuetMove, t: number) {\n\t\treturn Math.max(0, this.ready[kind] - t);\n\t}\n\n\t/** Is `kind` on offer with her at all (Back door: not when she switched it off). */\n\toffers(kind: DuetMove) {\n\t\treturn this.tune.her.prefs[kind] !== 'off';\n\t}\n\n\t/** Can `kind` start at round time t: on offer, no move running, off cooldown, in her, round on. */\n\tcanMove(kind: DuetMove, t: number) {\n\t\tconst s = this.state;\n\t\treturn this.offers(kind) && !s.outcome && !s.out && !this.active && t >= this.ready[kind];\n\t}\n\n\t/** Start a special move at round time t (ms). Returns its event, or null when it can't start now.\n\t *  The meter changes spread over the move; perfect (in its window) doubles its points. */\n\tmove(kind: DuetMove, t: number): DuetEvent | null {\n\t\tconst s = this.state,\n\t\t\tm = MOVES[kind],\n\t\t\ttu = this.tune;\n\t\tif (!this.canMove(kind, t)) return null;\n\t\tlet her: number,\n\t\t\this: number,\n\t\t\tflop = false,\n\t\t\tfx: DuetReaction[] = [];\n\t\tif (kind === 'tease') {\n\t\t\t// just the tip: she warms, he gets his breath back\n\t\t\ther = 0.04 * tu.perk;\n\t\t\this = -0.06;\n\t\t} else if (kind === 'balls') {\n\t\t\tflop = s.her < BALLS_MIN_HER;\n\t\t\ther = flop ? 0.01 : 0.08;\n\t\t\this = flop ? 0.06 : 0.04;\n\t\t\tif (!flop && tu.g) {\n\t\t\t\ther *= 1 + SIZE.gBalls * tu.g;\n\t\t\t\tfx.push('gspot');\n\t\t\t}\n\t\t\tif (!flop && tu.deep) {\n\t\t\t\ther += tu.deep;\n\t\t\t\tfx.push('deepspot');\n\t\t\t}\n\t\t} else if (kind === 'pound') {\n\t\t\tflop = t < MOVES.pound.window[0];\n\t\t\ther = flop ? 0.02 : 0.1;\n\t\t\this = flop ? 0.12 : 0.05;\n\t\t} else if (kind === 'between') {\n\t\t\t// he slides between her cheeks: she stays warm, he gets his breath back\n\t\t\ther = 0.015;\n\t\t\this = -0.09;\n\t\t} else if (kind === 'spank') {\n\t\t\ther = 0.03;\n\t\t\this = 0.01;\n\t\t} else if (kind === 'back') {\n\t\t\tflop = s.her < BACK_MIN_HER;\n\t\t\ther = 0.1;\n\t\t\this = 0.07;\n\t\t} else {\n\t\t\tthis.coolHeat(t);\n\t\t\ther = (0.06 * (tu.clit / tu.gain) * tu.perk) / (1 + this.heat);\n\t\t\tthis.heat += 1;\n\t\t\this = -0.02;\n\t\t}\n\t\t// her taste: a move she's not into cools her; loves / likes count for more\n\t\tconst pref = tu.her.prefs[kind],\n\t\t\tnot = pref === 'not';\n\t\t// Back door too soon, or with her not into it: too much, too soon\n\t\tif (kind === 'back' && (flop || not)) {\n\t\t\ther = -SIZE.tooMuchDrop;\n\t\t\tfx = ['toomuch'];\n\t\t} else if (not) {\n\t\t\ther = -PLAY.notDrop;\n\t\t\tfx = ['dislike'];\n\t\t} else {\n\t\t\ther *= PLAY.pref[pref] * tu.gain;\n\t\t\tif (!flop && (pref === 'loves' || pref === 'likes')) fx.unshift(pref);\n\t\t}\n\t\t// a hard move on a thick one before she is warm\n\t\tconst tooMuch = !not && (kind === 'balls' || kind === 'pound') && s.her < tu.tooSoon;\n\t\tif (tooMuch) {\n\t\t\ther = -SIZE.tooMuchDrop;\n\t\t\tfx = ['toomuch'];\n\t\t}\n\t\tconst perfect =\n\t\t\t!flop && !not && !tooMuch && fx[0] !== 'toomuch' && t >= m.window[0] && t < m.window[1];\n\t\tthis.ready[kind] = t + m.cooldown;\n\t\tthis.active = { kind, at: t, until: t + m.ms, her, his };\n\t\ts.move = kind;\n\t\ts.holding = false;\n\t\ts.movePts = Math.min(MOVE_PTS_MAX, s.movePts + m.pts * (perfect ? 2 : 1));\n\t\tconst ev: DuetEvent = { t, kind: 'move', move: kind, perfect, flop };\n\t\tthis.state.events.push(ev);\n\t\tfor (const r of fx) this.state.events.push({ t, kind: r, move: kind });\n\t\treturn ev;\n\t}\n\n\tprivate coolHeat(t: number) {\n\t\tthis.heat *= halfLife(t - this.heatT, CLIT.heatHalfMs);\n\t\tthis.heatT = t;\n\t}\n\n\t/** One tick of a finger rubbing her clit at round time t (ms). Returns the boost (0 when ignored). */\n\trub(t: number) {\n\t\tconst s = this.state;\n\t\tif (s.outcome || t < this.lastRub) return 0;\n\t\tif (t - this.lastRub > RUB.gestureGapMs) this.emit(t, 'rub');\n\t\tthis.lastRub = t;\n\t\tthis.coolHeat(t);\n\t\tconst band = this.band(t);\n\t\tconst inBand = !s.out && s.tempo >= band.lo && s.tempo <= band.hi;\n\t\tconst boost =\n\t\t\t(RUB.base * (inBand ? CLIT.inBand : 1) * this.tune.clit * this.tune.perk) / (1 + this.heat);\n\t\tthis.heat += RUB.heat;\n\t\ts.her = clamp01(s.her + boost);\n\t\treturn boost;\n\t}\n\n\t/** A tap on her clit at round time t (ms). Returns the boost it gave (0 when ignored). */\n\tclit(t: number) {\n\t\tconst s = this.state;\n\t\tif (s.outcome || t <= this.lastClit) return 0;\n\t\tthis.lastClit = t;\n\t\tthis.coolHeat(t);\n\t\tconst band = this.band(t);\n\t\tconst inBand = !s.out && s.tempo >= band.lo && s.tempo <= band.hi;\n\t\tconst boost = (CLIT.base * (inBand ? CLIT.inBand : 1) * this.tune.clit) / (1 + this.heat);\n\t\tthis.heat += 1;\n\t\ts.her = clamp01(s.her + boost);\n\t\tthis.emit(t, 'clit');\n\t\treturn boost;\n\t}\n\n\t/** A tap at round time t (ms). Taps must come in order; out-of-order or post-round taps are ignored. */\n\ttap(t: number) {\n\t\tconst s = this.state,\n\t\t\tlast = this.taps[this.taps.length - 1];\n\t\tif (\n\t\t\ts.outcome ||\n\t\t\tthis.active ||\n\t\t\t(last !== undefined && t <= last) ||\n\t\t\t(s.outAt !== null && t <= s.outAt)\n\t\t)\n\t\t\treturn;\n\t\tif (s.out) {\n\t\t\tif (t - s.outAt! >= REENTER_MS) {\n\t\t\t\ts.out = false;\n\t\t\t\tthis.lastIn = t;\n\t\t\t\tthis.taps = [t];\n\t\t\t\tthis.emit(t, 'reenter');\n\t\t\t} else {\n\t\t\t\ts.outAt = t;\n\t\t\t\tthis.emit(t, 'miss');\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthis.taps.push(t);\n\t\tconst n = this.taps.length;\n\t\tif (n < 4 || s.holding) return;\n\t\tconst iv = t - this.taps[n - 2],\n\t\t\tprev = this.taps[n - 2] - this.taps[n - 3];\n\t\tconst band = this.band(t),\n\t\t\tfrantic = 1000 / (band.hi * SLIP_OVER * this.tune.slip);\n\t\tlet run = 0;\n\t\tfor (let i = n - 1; i > 0 && run < SLIP_RUN && this.taps[i] - this.taps[i - 1] < frantic; i--)\n\t\t\trun++;\n\t\tif (run >= SLIP_RUN && t - this.lastIn > SLIP_COOLDOWN) {\n\t\t\ts.out = true;\n\t\t\ts.outAt = t;\n\t\t\ts.combo = 0;\n\t\t\ts.her = clamp01(s.her - SLIP_PENALTY.her);\n\t\t\ts.his = clamp01(s.his + SLIP_PENALTY.his);\n\t\t\tthis.taps = [];\n\t\t\tthis.emit(t, 'slip');\n\t\t\treturn;\n\t\t}\n\t\tconst perfect =\n\t\t\tMath.abs(1000 / iv - band.centre) <= PERFECT_TOL * band.centre &&\n\t\t\tMath.abs(iv - prev) <= 0.15 * prev;\n\t\ts.combo = perfect ? s.combo + 1 : 0;\n\t\tif (s.combo >= COMBO) {\n\t\t\ts.combo = 0;\n\t\t\ts.her = clamp01(s.her + DEEP_BONUS.her * this.tune.gain);\n\t\t\ts.his = clamp01(s.his + DEEP_BONUS.his);\n\t\t\tthis.emit(t, 'deep');\n\t\t}\n\t}\n\n\tprivate emit(t: number, kind: DuetEventKind) {\n\t\tthis.state.events.push({ t, kind });\n\t}\n\n\t/** Press (true) or release (false) the hold at round time t (ms). */\n\tsetHold(t: number, on: boolean) {\n\t\tif (this.state.outcome) return;\n\t\tthis.holds.push({ at: t, on });\n\t}\n\n\t/** Run the rules up to round time t (ms), in fixed steps. */\n\tadvance(t: number) {\n\t\tconst s = this.state;\n\t\twhile (!s.outcome && s.t + STEP_MS <= t + 1e-6) this.step();\n\t}\n\n\tprivate step() {\n\t\tconst s = this.state,\n\t\t\tdt = STEP_MS / 1000;\n\t\tthis.n++;\n\t\t// counted in steps, so long rounds don't drift from float sums\n\t\ts.t = this.n * STEP_MS;\n\t\twhile (this.holds.length && this.holds[0].at <= s.t) {\n\t\t\tconst h = this.holds.shift()!;\n\t\t\tif (this.hold && !h.on) this.seam = h.at;\n\t\t\tthis.hold = h.on;\n\t\t}\n\t\tconst mv = this.active;\n\t\tif (mv && s.t >= mv.until) {\n\t\t\t// the rhythm picks up where it was: the taps before the move slide past it\n\t\t\tconst d = mv.until - mv.at;\n\t\t\tthis.taps = this.taps.map((x) => x + d);\n\t\t\tthis.seam = mv.until;\n\t\t\tthis.active = null;\n\t\t\ts.move = null;\n\t\t}\n\t\ts.holding = this.hold && !s.out && !this.active;\n\t\tif (s.pose === 0 && s.t >= SWITCH_MS) {\n\t\t\ts.pose = 1;\n\t\t\tthis.emit(s.t, 'switch');\n\t\t}\n\t\t// tempo and steadiness from the last few taps up to now (rec[r0..7], oldest first; no\n\t\t// allocation: this runs 120 times a second). The interval across a seam doesn't count, and\n\t\t// one about 2x or 3x the median is that many beats (beatsIn)\n\t\tconst rec = this.rec,\n\t\t\tiv = this.iv,\n\t\t\tsrt = this.srt;\n\t\tlet r0 = 8;\n\t\tfor (let i = this.taps.length - 1; i >= 0 && r0 > 0; i--)\n\t\t\tif (this.taps[i] <= s.t) rec[--r0] = this.taps[i];\n\t\tlet n = 0;\n\t\tfor (let k = r0 + 1; k < 8; k++)\n\t\t\tif (!(rec[k - 1] < this.seam && rec[k] >= this.seam)) iv[n++] = rec[k] - rec[k - 1];\n\t\tlet tempo = 0,\n\t\t\tjitter = 0;\n\t\tif (n >= 1) {\n\t\t\tfor (let k = 0; k < n; k++) {\n\t\t\t\tlet j = k;\n\t\t\t\tfor (; j > 0 && srt[j - 1] > iv[k]; j--) srt[j] = srt[j - 1];\n\t\t\t\tsrt[j] = iv[k];\n\t\t\t}\n\t\t\tconst med = srt[n >> 1];\n\t\t\tlet beats = 0,\n\t\t\t\tsum = 0;\n\t\t\tfor (let k = 0; k < n; k++) {\n\t\t\t\tbeats += n >= 3 ? beatsIn(iv[k] / med) : 1;\n\t\t\t\tsum += iv[k];\n\t\t\t}\n\t\t\tconst mean = sum / beats;\n\t\t\tlet v = 0;\n\t\t\tfor (let k = 0; k < n; k++) {\n\t\t\t\tconst b = n >= 3 ? beatsIn(iv[k] / med) : 1;\n\t\t\t\tconst d = iv[k] / b - mean;\n\t\t\t\tv += b * d * d;\n\t\t\t}\n\t\t\tconst sd = Math.sqrt(v / beats);\n\t\t\tconst idle = s.t - rec[7] > Math.max(IDLE_MIN_MS, IDLE_FACTOR * mean);\n\t\t\tif (!idle) {\n\t\t\t\ttempo = 1000 / mean;\n\t\t\t\tjitter = beats >= 2 ? clamp01(sd / mean) : 0.15;\n\t\t\t}\n\t\t}\n\t\ts.tempo = tempo;\n\t\ts.jitter = jitter;\n\t\tconst tu = this.tune,\n\t\t\tband = this.band(s.t),\n\t\t\thw = band.centre * tu.half;\n\t\ts.offBand = tempo > 0 ? Math.max(-1, Math.min(1, (tempo - band.centre) / (2 * hw))) : -1;\n\t\tif (this.active) {\n\t\t\t// a special move: its own meter changes, spread over it\n\t\t\tconst a = this.active,\n\t\t\t\tf = STEP_MS / (a.until - a.at);\n\t\t\ts.her = clamp01(s.her + a.her * f);\n\t\t\ts.his = clamp01(s.his + a.his * f);\n\t\t} else if (s.out) {\n\t\t\ts.tempo = 0;\n\t\t\ts.her = clamp01(s.her - RATES.herIdle * dt);\n\t\t} else if (s.holding) {\n\t\t\ts.her = clamp01(s.her + RATES.herHold * dt * tu.gain * (1 + SIZE.gHold * tu.g));\n\t\t\ts.his = clamp01(s.his + RATES.hisHold * dt);\n\t\t} else if (tempo > 0) {\n\t\t\t// q: 1 at the band's centre, still high most of the way out (forgiving), 0 at its edge,\n\t\t\t// negative outside\n\t\t\tconst a = Math.abs(tempo - band.centre) / hw,\n\t\t\t\tq = 1 - a * a * a;\n\t\t\tconst steady = clamp01(1 - jitter * 1.8),\n\t\t\t\tease = clamp01(1 - STEADY.slope * Math.max(0, jitter - STEADY.dead));\n\t\t\tif (q > 0) {\n\t\t\t\t// his girth (warm-up, then fullness) and curve (slow strokes), her sensitivity\n\t\t\t\tlet k = tu.gain * (s.her < SIZE.warm ? tu.cold : tu.full);\n\t\t\t\tif (tu.g && tempo <= band.centre) k *= 1 + SIZE.gSlow * tu.g;\n\t\t\t\ts.her += RATES.herGain * q * ease * dt * k;\n\t\t\t} else s.her -= RATES.herLoss * Math.min(1, -q) * dt;\n\t\t\t// erratic tapping cools her even inside the band\n\t\t\ts.her -= RATES.herLoss * clamp01(jitter * 1.8 - 1) * dt;\n\t\t\ts.her = clamp01(s.her);\n\t\t\ts.his = clamp01(s.his + (RATES.hisBase + RATES.hisK * tempo * tempo) * dt * tu.stamina);\n\t\t\ts.rhythmSum += Math.max(0, q) * steady * STEP_MS;\n\t\t\ts.activeMs += STEP_MS;\n\t\t} else {\n\t\t\ts.her = clamp01(s.her - RATES.herIdle * dt);\n\t\t}\n\t\tif (s.his >= EDGE !== s.edge) {\n\t\t\ts.edge = s.his >= EDGE;\n\t\t\tif (s.edge) this.emit(s.t, 'edge');\n\t\t}\n\t\tif (s.her >= 1) this.end('climax');\n\t\telse if (s.his >= 1) this.end('early');\n\t\telse if (s.t >= ROUND_MS - 1e-6) this.end('timeout');\n\t}\n\n\tprivate end(o: DuetOutcome) {\n\t\tthis.state.outcome = o;\n\t\tthis.state.endT = this.state.t;\n\t}\n\n\t/** Score and end title (valid once the round is over; a running round scores what it has). */\n\tresult(): DuetResult {\n\t\treturn scoreState(this.state);\n\t}\n}\n\nexport interface DuetResult {\n\trhythm: number;\n\tstamina: number;\n\tscore: number;\n\ttitle: string;\n}\n\nexport function scoreState(s: DuetGameState): DuetResult {\n\tconst rhythm = Math.round(100 * (s.activeMs > 0 ? s.rhythmSum / s.activeMs : 0));\n\tconst stamina = s.outcome === 'early' ? 0 : Math.round(100 * (1 - s.his));\n\t// a round that never finishes her can't score above 50 (before move points)\n\tlet score = Math.round(0.6 * rhythm + 0.4 * stamina);\n\tif (s.outcome !== 'climax') score = Math.min(score, 50);\n\tscore = Math.min(100, score + s.movePts);\n\treturn { rhythm, stamina, score, title: titleFor(s, rhythm) };\n}\n\nfunction titleFor(s: DuetGameState, rhythm: number): string {\n\tif (s.outcome === 'early') return 'Too eager';\n\tif (s.outcome === 'climax') {\n\t\tif (rhythm >= 85) return 'Perfect sync';\n\t\tif ((s.endT ?? 0) >= 38_000) return 'Slow burn';\n\t\treturn 'In the groove';\n\t}\n\tif (s.outcome === 'timeout') return s.her >= 0.7 ? 'So close' : 'Out of time';\n\treturn '';\n}\n\n/**\n * 0.5 ** (dt / half) for dt >= 0 (a negative dt counts as 0), from + - * / only, so it gives the same\n * bits on every engine (simulate() replays logs: the server and every browser must agree). The whole\n * halvings are exact; 2^-f for the rest is its Taylor series (relative error under 1e-14).\n */\nexport function halfLife(dt: number, half: number) {\n\tlet x = dt / half;\n\tif (!(x > 0)) return 1;\n\tlet r = 1;\n\twhile (x >= 1) {\n\t\tr *= 0.5;\n\t\tx -= 1;\n\t\tif (r < 1e-300) return 0;\n\t}\n\t// 2^-x = e^(-x ln 2), x in [0, 1)\n\tconst y = -x * 0.6931471805599453;\n\tlet sum = 1,\n\t\tterm = 1;\n\tfor (let k = 1; k <= 14; k++) {\n\t\tterm = (term * y) / k;\n\t\tsum += term;\n\t}\n\treturn r * sum;\n}\n\n/** After her climax: rhythmic contractions, 0..1, decaying over ~4 s (ms since the climax). */\nexport function climaxPulse(ms: number): number {\n\tif (ms < 0 || ms > 4200) return 0;\n\tconst s = ms / 1000,\n\t\t// contractions start ~0.8 s apart and spread out\n\t\tph = (2 * Math.PI * s) / (0.75 + 0.12 * s);\n\treturn Math.max(0, Math.sin(ph)) ** 2 * Math.exp(-s * 0.55);\n}\n\n/** His pulses: a little later and slower than hers. */\nexport function hisPulse(ms: number): number {\n\treturn climaxPulse(ms - 250) * 0.9;\n}\n\n/** Haptics hook: a vibration pattern per moment (navigator.vibrate shape). Stub: callers decide. */\nexport const HAPTICS = {\n\tstroke: [8],\n\tclimax: [60, 120, 60, 160, 50, 220, 40],\n\tearly: [200]\n} as const;\n\n/** Vibrate if the platform can (iOS Safari can't: a no-op there). */\nexport function vibrate(pattern: readonly number[]) {\n\tif (typeof navigator !== 'undefined' && typeof navigator.vibrate === 'function')\n\t\tnavigator.vibrate([...pattern]);\n}\n"],"version":3}