AI using A*

 

just part of the overall function shown here

Nodes and edges are mapped out to form the path, once it reaches the closest node to the destination the fish begins to traverse the found path

Using my own maths library I came up with my own version of A* pathfinding and used the analogy of fish in a pond to demonstrate how it works. There are two fish, the orange one follows the other fish when it comes within a certain range of it, the blue fish wanders until food is dropped and then goes to the food with A*. I’ve included a screenshot snippet of the start of the most complicated part of that pathfinding. This was made in SDL2 with C++ and externally sourced images.