Spielerando

An enemy keeps switching between chasing and wandering, twitching in place

The creature jitters at the edge of its sight instead of choosing. Your AI will blame the animation. This entry reads the record of the creature's mode changes and finds the stretches where it changed its mind many times in a few seconds.

Why this works

A creature that uses one distance to start and stop chasing flips whenever the player stands at that distance. Counting changes inside a short window proves it and points at the exact time to look at.

When not to use it

Fast switching is fine when it is meant to be erratic, such as a skittish animal. Set the allowed changes higher for it.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 2 common mistakes and the fix
  • 46 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 "An enemy keeps switching between chasing and wandering, twitching in place" (read_entry survival-enemy-flips-between-modes) 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