Skip to content

Avoid repeating entries until all have been picked#1

Open
reinsch82 wants to merge 1 commit into
jbartok:mainfrom
reinsch82:no-repeat-picks
Open

Avoid repeating entries until all have been picked#1
reinsch82 wants to merge 1 commit into
jbartok:mainfrom
reinsch82:no-repeat-picks

Conversation

@reinsch82

Copy link
Copy Markdown

Summary

  • Replace pure random selection with a shuffle bag: every entry is picked exactly once per round before any entry can repeat
  • Persist the remaining pool in localStorage (keyed by the sorted item set), so reloads continue the current round instead of repeating — relevant since the page auto-picks on load
  • Prevent a new round from starting with the same entry the previous round ended on, so the same name never appears twice in a row
  • Show a 🔄 marker on the last pick of each round
  • Add a Reset button that clears the stored pool for the current item set only

Testing

  • Verified the pick logic with a 10,000-pick simulation: each round covers all items exactly once, with no back-to-back repeats
  • Manual check: python3 -m http.server and open http://localhost:8000/?items=Alice,Bob,Carol,Dave

Replace pure random selection with a shuffle bag: each entry is
picked once per round, persisted in localStorage (keyed by item set)
so reloads continue the round. A new round never starts with the
entry the previous round ended on. Adds a Reset button to clear the
stored pool for the current item set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant