Spielerando

A drop that is guaranteed after ten misses still fails on the next try

Adding small chance bonuses again and again with ordinary decimals drifts by a hair, and a hair is enough to miss a guarantee or to break a promise like exactly a quarter. The cure is to count in whole units and compare in whole units.

Why this works

Computers cannot hold most decimals exactly, so tiny errors build up with every addition, and a promise like certain after enough misses can slip by a hair. Counting in whole units, which are held exactly, makes every sum and every comparison come out as written.

When not to use it

Skip it when exactness is not a promise to the player, for example for a small effect that nobody will count or measure. Whole units add conversions and a limit on how fine a chance can be. Plain decimals are fine there.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 3 common mistakes and the fix
  • 30 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 "A drop that is guaranteed after ten misses still fails on the next try" (read_entry luck-bonuses-counted-in-whole-units-not-fractions) 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