Lecture
Obstacle traversal by enemies and non-player characters (going around, jumping over, jumping up onto, crawling, etc.) can be implemented using various algorithms and approaches, depending on the complexity of the AI and the environment. Here are the main algorithms and methods used for obstacle traversal:
Each state describes a behavior (for example, "walk", "jump", "stand", "fall"). When an obstacle is detected, the character transitions to the appropriate state:
Walk → obstacle → Jump
Jump → reaching the platform → Walk
Simple, works well for patrolling enemies and NPCs.
Scanning the space with rays pointing down, forward, and up makes it possible to:
detect ledges (if there is no ground underfoot);
see walls ahead;
understand whether it is possible to jump over. Then simple physics checks + conditions are used
Suitable for simple AI:
if (isGroundAhead() && !isWallAhead())
{
moveRight();
}
else
if (isWallAhead() && canJump())
{
jump();
}
Used in Unity, Godot, Phaser, and other engines.

Applicable for more complex levels, where you need to reach a target while going around obstacles:
The world is divided into a grid (in 2D — a tile map);
A* finds the shortest path;
The sprite moves along the found coordinates.
Requires configuring the "cost" of tiles: whether you can jump there, how long the jump is, and so on.
Used in cases where A* is not suitable.
The space is broken down into platforms and links between them (whether you can jump from one to another).
The character chooses the optimal route along the graph's vertices.

A structured form of AI behavior.
You can specify: "If there is an obstacle — jump", "If there is an enemy — attack", and so on.
A very flexible system, often used in large projects.

For advanced AI:
The AI learns to overcome obstacles on its own;
Used in experiments (for example, in OpenAI Gym);
Impractical for simple games — expensive to develop and unstable in behavior.
example

To traverse a path in a game using reinforcement learning (RL), the process can be represented as a series of stages that repeat in a loop. Here is what it would look like step by step:
Initialization:
The agent starts in an initial state.
The initial values of the Q-function (or the policy) are random or zero.
Obtaining the current state of the environment:
For example: "I am standing in front of a pit", or "There is an enemy in front of me".
Choosing an action:
A strategy is used (for example, ε-greedy): the agent chooses either the best known action or a random one for exploration.
For example: "Jump", "Attack", "Go right".
Performing the action and transitioning:
The agent acts in the environment.
The environment updates: a new position, a new situation.
Receiving a reward:
The agent gets feedback:
+1 for a successful jump,
–1 for falling into a pit,
+10 for reaching the goal.
Updating the strategy (learning):
The Q-function or neural network is adjusted based on the new experience.
The agent "learns" so as to act better in the future.
Transitioning to a new state and repeating:
The agent is now in a new state, and the loop starts over.
| Obstacle | Possible solution algorithm |
|---|---|
| Ledge | Downward raycast check |
| Low passage | "Crouch" state |
| Wall | raycast + "jump" |
| Moving platform | FSM + platform tracking |
| Enemy | FSM / Behavior Tree |
Comments