You need some sort of A* to create good ai, with a* there are multiple ways to go.
I got a A* based on breath first search also uses the KD_tree to find a close node, for example: you click somewhere then you can grab nodes within range ot closest node and build a path to/from it:
In this case it’s used for a tile based game, but you can rip the codes and use some nodes instead of tiles.
So now that you can create a path you simply need to make the ai behavior.
- use path to patrol
- use path to walk fastest way to object/player
- along the way check if something is near or if there is an action to do before continuing the path.
- engage the player in combat, etc.
- return to last node used from path and continue