Wandering patrolling AI character using only python in upbge

And that’s where you are wrong,

  • how would you pick a random spot
  • how much time does it needs to walk
  • what direction does it needs to walk to
  • what if it keeps walking against a wall

So it gets complicated faster then you think

  • add radar
  • add rays
  • calculate stuff based on above sensors
  • figure out the direction
  • figure out when to turn away from something
  • found player… figure out how to chase it
  • etc.

Then after wasting time to try to get something up and running, you realize that you could use some nodes. Then another post is created here, how to make path from nodes? So instead we offer the best and easiest solution, use a node based A* algorithm to create directions/paths instantly without the hassle to calculate everything with every step you take. And that path can be as random as you like just by randomly selecting a node and calculate the path. This automatically avoids corner calculations and wall banging due to the path is already laid out and always finds it target, just by feeding the script the closest node it is chasing, or a random one to just wander around.

i had the same issue when i dived into pathing, tried a lot of stuff, best option use A* it saves so much headaches.

Here is some food for your brain so you know where we come from… sorta: