Hide exactly five chests in a hundred spots without two landing together
Rolling a spot for each chest sometimes puts two in the same place, and the usual fix of rolling again makes the cost unpredictable and the result slightly tilted. This shows a method that always takes exactly as many random numbers as chests and treats every combination equally.
Why this works
Fairness here means every possible set of places is equally likely, and the cost is fixed in advance. Working through the places from the end and moving a clash to the spare spot achieves both without ever redrawing.
When not to use it
Skip it when the spots must also keep a minimum distance or follow rules about the terrain. Then draw from a list of allowed places, or shuffle the whole list when you need almost every spot anyway.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 4 common mistakes and the fix
- 25 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 "Hide exactly five chests in a hundred spots without two landing together" (read_entry scatter-chests-distinct-spots) 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