Seek + Avoid (Steering)

Objective:

Avoid objects using steering behavior while actively seeking a target.

How I Achieved it:

I implemented a steering system where the ship calculates a desired velocity toward the target and adjusts its heading based on the difference from its current direction. Collision “whiskers” detect nearby obstacles and trigger speed reduction and steering away from hazards. Position is updated each frame using a kinematic equation, and velocity is clamped to maintain control. This creates smooth pursuit while dynamically avoiding collisions.

Search Algorithm + Path Calculation

Objective:

Implement a grid-based search algorithm capable of finding the shortest path to a target while allowing flexible path cost calculation using different heuristics.

How I Achieved it:

I created a 2D tile grid where each tile stores its position, movement cost, and references to its four direct neighbors (top, right, bottom, left). For path cost calculation, I implemented two heuristic options — Manhattan distance for grid-based movement and Euclidean distance for diagonal-friendly calculations. The algorithm starts from the ship’s tile, evaluates all accessible neighbors, and selects the tile with the lowest combined movement and heuristic cost. This process repeats until the goal tile is found. The path is then stored in a list, and the ship moves along it step-by-step, centered on each tile. The system also outputs the path coordinates and length, making debugging and visualization straightforward.

Path calculation (Nodes +LOS)

Objective:

Calculate valid movement paths using a node-based grid system, ensuring each path segment maintains a clear line of sight (LOS) between the player, target, and intermediate nodes.

How I Achieved it:

I structured the environment as a grid of PathNode objects, each storing its world position and LOS distance. Obstacles are checked during grid creation so only unobstructed nodes remain. For LOS detection, I implemented ray-based checks that verify if a node can see the player or target without being blocked by obstacles. The system first measures the distance between the node and the target, then filters out any objects closer than the target that are not part of the path system. If the LOS ray intersects only valid space, the node is flagged as having LOS. I extended this to check all nodes against both the player and target, marking those with mutual visibility. This approach ensures pathfinding decisions are based on accessible nodes and clear visual connections, allowing accurate and obstacle-aware route calculation.