A computer-controlled character that knows if it can clear a gap, and backs up first
Computer characters either jump into every gap and fall, or never dare. The trick is to know the speed they will really have at the edge, not the speed they have now. Here is how to decide yes, no or take a run-up, and when to press jump.
Why this works
A jump goes as far as the speed at the edge allows, and that speed is what the runner will have there, not what it has now. Asking about the speed at the edge lets the character say yes, no, or back up first, instead of guessing.
When not to use it
Not needed when the gaps are all the same and short, or when enemies should be easy to fool. A simple rule such as always jump at the edge is enough then, and clever enemies that never fall may make the level too safe.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- 31 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 "A computer-controlled character that knows if it can clear a gap, and backs up first" (read_entry ai-run-up-before-a-gap) 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