Spielerando

The bag refuses an item that should just fit, or takes one that should not

With a limit of three kilos and items of a tenth and two tenths, the game claims the total is a hair too much. This is not your numbers: it is how computers add small fractions. Your AI can do the weights in whole units and say exactly how much is free.

Why this works

Computers store fractions like a tenth in binary, where they have no exact form, so small errors add up and break exact comparisons at the limit. Whole units have no such error, and the comparison becomes true or false for the right reasons.

When not to use it

If the limit is soft, such as a speed penalty that grows with weight, a hair makes no difference and plain decimals are fine. Use whole units where a hard yes or no is shown to the player.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 3 common mistakes and the fix
  • 23 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 "The bag refuses an item that should just fit, or takes one that should not" (read_entry rpg-bag-weight-limit-off-by-a-hair) 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