Dragging a selection box from right to left selects nothing, and a click clears everything
Selecting units looks easy until players drag the wrong way, click a bit sloppily or hold a key to add. This entry gives your AI a selection routine that treats a tiny drag as a click, works from any corner and keeps the old group when adding.
Why this works
Mouse hands shake, so a click is never a single pixel; below a small distance a drag is a click. And a rectangle is defined by two points in any order, so normalise it first instead of assuming the second point is the bottom right.
When not to use it
Skip it on touch screens, where a different gesture such as tapping a unit then a second button is more reliable than dragging a box with a finger.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- 39 lines of example code with 5 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Dragging a selection box from right to left selects nothing, and a click clears everything" (read_entry strategy-drag-select-picks-wrong-units) 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