Spielerando

What is the real chance that a scattered shot hits a round target?

A weapon scatters shots over an area and the enemy covers only part of it. Guessing a percentage by distance feels wrong on the range. The exact answer comes from comparing two areas, and one corner case makes naive code return nonsense or crash.

Why this works

When shots land evenly over an area, the chance of hitting a part of it is simply that part's share of the whole. Chance becomes a question of overlap between two shapes, and comparing areas gives the true answer, where a percentage guessed from distance never will.

When not to use it

Skip it when the target is not round, or the spread is not even, as with a shotgun pattern that has a dense core. The overlap of two circles then gives the wrong answer. Sample many simulated shots against the real shape and count the hits.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 3 common mistakes and the fix
  • 21 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 "What is the real chance that a scattered shot hits a round target?" (read_entry circle-target-hit-chance-from-spread-overlap) 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