Spielerando

Price each upgrade level without rounding errors creeping in

Each level of a building costs a bit more than the last, and in some spots the shown price is one more than the maths says, because a computer adds tiny errors that rounding up turns into a whole unit. This entry gets the same price on every device, and the total for several levels.

Why this works

A price is a promise, and a promise must read the same on every device. Computers that work with decimals pick up tiny errors that rounding up turns into a whole unit, so counting in whole numbers and dividing last keeps every player's price identical.

When not to use it

Skip it when prices are looked up from a fixed table the designer wrote by hand, which is easier to balance and to read. Also skip it when the game runs on one device with no shared totals and nobody compares numbers.

In the full entry

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

Say this to your AI

Use the Spielerando entry "Price each upgrade level without rounding errors creeping in" (read_entry upgrade-cost-exact-growth) 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