Spielerando

The happiness meter shows NaN, or 130 percent, when a city has no parks yet

A weighted average breaks in two ways: an empty group divides by zero, and one oversized score drags the total out of range. This entry gives your AI a score that leaves out groups with nothing to measure and caps each single value first.

Why this works

A group with nothing in it has no opinion, so it should not vote at all. If it counted as zero, a young city would look miserable; if it counted as perfect, an empty one would look happy. The weights have to be renormalised over the groups that have data.

When not to use it

Skip it when a missing group should hurt on purpose, such as a city that must have a hospital. Then give the missing group a fixed low score instead of leaving it out.

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 3 checks that pass
  • How your AI shows you that it works

Say this to your AI

Use the Spielerando entry "The happiness meter shows NaN, or 130 percent, when a city has no parks yet" (read_entry strategy-happiness-shows-nan-or-over-100) 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