[WIP] Pathfinding AI for dummy bots

This is an old version. I have made a far better version by now, wich you will find here.

I have played around with dummy bots a bit and tried to get some pathfinding done and came up with quite a decent pathfinding-AI. Its not perfect or anything, but as long as we dont have a built-in graph class in workshop, I dont think I can make something better.

ZGTKX - Im sorry that the code is such a mess, I will clean it up later, when I release this as a tool.

Known Issues:

  • The bot can’t reach a highground position and chances are low that it will find the stairs, if there are some.
  • There is a very low chance that the bot will fall down a cliff - unfortunately I can’t fix this without breaking the algorithm.

Usage (WIP version):

  • Walk out of the spawnroom to spawn an ana dummybot
  • Go to a position you want and Crouch to initiate the pathfinding algorithm with the destination being your position. Crouch again to interrupt the pathfinding.
  • Press Interact and the bot will stick close to you (no pathfinding). Press it again and the bot will stop following. (mainly for debugging)
  • Press Jump to toggle slow motion. (mainly for debugging)

The UI (mainly for debugging):

  • The blue light shaft and red arrow are marking the (current) destination of the pathfinding algorithm.
  • The green and red light shaft are marking the orthogonal vector that is used by the “is-stuck-in-circle-handling”.
  • The small messages are displaying the current action the bot is doing (right, left, forward, backward).
  • The big message (“2: Error”) displays if the bot is stuck in a circle and the algorithm tries to handle it.

The Algorithm:

  • The bot moves directly to the destination (D) as default action.
  • If the bot reaches D it will remove it from the array and go for the next destination or end the algorithm if its the final destination.
  • If the bot moves against an obstacle or cliff it will turn right.
  • If the bot just turned right and detects no obstacle on its left it will turn left and return to the default action after some time.
  • If the bot detects no obstacle but still gets stuck (no movement), it will walk backwards for a brief moment and then try again. (This happens if it walks towards thin walls)
  • If the bot gets stuck (no movement) but still has a high speed value (yes, this can happen - dont ask me why :man_shrugging:), it will be detected by another rule and handled the same way.
  • If the bot gets stuck in a circle (is moving between the same positions over and over; this will nearly always happen in small rooms) it chooses a new destination ( D’ ) and walks towards it. It also changes the turning direction from right to left (or left to right).

The dummy bot has a high rate of reaching its destination with this algorithm, even if he seems to behave kind of weird and random sometimes. Some things that needs to be done is cleaning up the code and finding a solution for the rare case that D’ is unreachable.
I hope someone will find this useful and if you like this or notice some cases, in wich the bot still gets stuck, please tell me about it :smiley:

3 Likes

It’s cool. It’s like walking the labyrinth against the wall. I also made a similar moving system, but it is now in the PTR and can’t be taken out. Share my AI design

1 Like

As I see, you are doing some exploring and map building, wich is an interesting idea. If you move it to live, id really like to try it out and see how it works :slight_smile:

I looked at your code. your method is interesting and you worked really hard on it. but in some maps like Volskaya Industries, your bot will take a lot of time to get out of a small room (and sometimes fell off and die). I think all that bot need is the location of the exit of that room and get out of it through there and it would be so easy to reach the destination.

So I decided to create another pathfinder method witch you have to specify every points and the bot will go directly to those points. so now our bot knows where is the exits and the entrances and our bot can go any places like high grounds and exit and enter easily and…

the code is R5F73
Crouch to set the positions that bot will go, press ability 2 to create the bot and press interact key to tell the bot to start moving.

2 Likes

I didnt try your code yet, but yes, that would be the optimised method for pathfinding. Though I’m really courios how you made it without a graph (or how you made a graph in workshop with arrays lol). I will look into your code later.

Still my method is independent of the map. But as soon as you have a map of specified points for each map my method will be pointless :slight_smile:

1 Like

I just defined that If player in slot 0 crouch, the position of the player will be saved in array P (in my code). Also there’s a map detector (unfortunately I can’t include links, if you search this forum you’ll find it) and you can save the vectors of the entrances of that specific map into array P and then that’s it, a perfect pathfinder. you can even save the position of the health packs

1 Like

My Bots have a working pathing system for all control map. If you wanna play the mode: COOP VS AI (Custom Bots/Legendary AI)

2 Likes

Would be nice if overwatch developers implement an advanced pathfinding support in workshop. but i think that devs won’t do that.

2 Likes

I tried to save positions in an global var then use Distance between positions to get closest position to go, but in my implementation, bots cannot find a correct position for example if Y Of target is greater than Y Of bot, bots stay stuck stopped in same position. I’m trying to find alternatives do that, i’m searching about simplest pathfinding alg, since workshop can crash easy if lot of actions running at same time (specially action loops).

No worries, Ive got a working algorithm (and a way better one than I shared in this thread). It just needs a few tests and a slight overhaul to make it easier to integrate before I can share it :slight_smile:

2 Likes