Spielerando

Stop enemy units from switching targets back and forth every turn

When two targets look almost equally good, an enemy that picks the best one afresh every turn runs left, then right, then left again and never attacks anything. Here is a small rule that keeps a choice until something clearly better appears, and picks the same one every time on a tie.

Why this works

When two options score almost the same, tiny changes flip the winner each turn. Giving the current choice a small head start means a rival must be clearly better to take over, and a fixed rule for exact ties removes the last source of flicker.

When not to use it

Wrong for enemies that should look hard to predict or should hunt the weakest target each time, like a pack of wolves. The head start also makes them slow to notice a sudden, truly better target if you set it too high.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 3 common mistakes and the fix
  • 13 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 "Stop enemy units from switching targets back and forth every turn" (read_entry enemy-target-choice-without-dithering) 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