A chest should give three different items, not the same one twice
Drawing several rewards from one weighted table sounds easy, until the common sword shows up three times or the rarest item can never appear together with another. This entry shows how to draw without repeats and keep the odds meaningful.
Why this works
Once an item is taken, the remaining ones share the whole chance among themselves, so the table is a ranking of how likely things are, not a fixed promise. Taking out each winner before the next pick is the only way to guarantee no doubles.
When not to use it
Skip it when duplicates are welcome or even the fun, such as stacking coins or ammunition, or when a chest must always hold a certain thing. Draw those pieces separately and keep this method for the variable part.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- 29 lines of example code with 5 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "A chest should give three different items, not the same one twice" (read_entry chest-draws-distinct-weighted-items) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP