Problem
`selectFrames` in src/frames.ts is supposed to always include one wildcard frame, but for small `n` the guarantee is probabilistic instead of deterministic:
```ts
const picked = shuffled.slice(0, Math.max(1, n - 1));
const wildPick = wild[Math.floor(Math.random() * wild.length)];
if (!picked.find((f) => f.id === wildPick.id)) picked.push(wildPick);
return picked.slice(0, n);
```
At `n=1`, `picked` already has 1 element (since `Math.max(1, 0) = 1`), so `wildPick` gets pushed to make it 2, then `slice(0, 1)` throws it away — the wildcard is dropped whenever the first picked frame isn't already the wildcard, which is most of the time.
Fix
Reserve the wildcard slot before picking the rest:
```ts
const wildPick = wild[Math.floor(Math.random() * wild.length)];
const remaining = pool.filter((f) => f.id !== wildPick.id);
const picked = shuffle(remaining).slice(0, Math.max(0, n - 1));
return [wildPick, ...picked].slice(0, n);
```
Add a regression test asserting `selectFrames(1, ...)` always returns a frame tagged `wild`.
(Re-filed as part of a backlog reset; previously tracked as #37.)
Problem
`selectFrames` in src/frames.ts is supposed to always include one wildcard frame, but for small `n` the guarantee is probabilistic instead of deterministic:
```ts
const picked = shuffled.slice(0, Math.max(1, n - 1));
const wildPick = wild[Math.floor(Math.random() * wild.length)];
if (!picked.find((f) => f.id === wildPick.id)) picked.push(wildPick);
return picked.slice(0, n);
```
At `n=1`, `picked` already has 1 element (since `Math.max(1, 0) = 1`), so `wildPick` gets pushed to make it 2, then `slice(0, 1)` throws it away — the wildcard is dropped whenever the first picked frame isn't already the wildcard, which is most of the time.
Fix
Reserve the wildcard slot before picking the rest:
```ts
const wildPick = wild[Math.floor(Math.random() * wild.length)];
const remaining = pool.filter((f) => f.id !== wildPick.id);
const picked = shuffle(remaining).slice(0, Math.max(0, n - 1));
return [wildPick, ...picked].slice(0, n);
```
Add a regression test asserting `selectFrames(1, ...)` always returns a frame tagged `wild`.
(Re-filed as part of a backlog reset; previously tracked as #37.)