Spielerando

Choose a squad of different enemy types by weight, with no type twice

Drawing from a weighted list until you have enough different ones is slow and skews the odds when the list is short. There is a way to give every type one random score and keep the best few, so the likelier types are favoured exactly as the weights say.

Why this works

Give each candidate one score that is biased by its weight, then keep the best few. A heavier item tends to score higher, a lighter one can still win by luck, and no item can appear twice. One pass is enough, with no retries to skew the odds.

When not to use it

Skip it when repeats are fine or wanted, such as a squad that may contain several of the same grunt. Then a plain weighted pick each time is simpler. Also skip it for a handful of fixed combinations that you can simply list.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 3 common mistakes and the fix
  • 16 lines of example code with 4 checks that pass
  • How your AI shows you that it works

Say this to your AI

Use the Spielerando entry "Choose a squad of different enemy types by weight, with no type twice" (read_entry pick-several-different-enemies-by-weight-without-repeats) 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