Jump to content

Artificial Intelligence - Bot path finding


Toady
 Share

Recommended Posts

@kirby - Thank you :)

@Secure - Well I wouldnt go there hehe :) Thank you.

UPDATE:

Added an example in the source code to help people get started very easily. I also got rid of that pop up box displaying the time and put the time in the gui instead.

I improved speed by ~20%. Good right? hope so.

www.itoady.com

A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding

Link to comment
Share on other sites

Updated - Now Faster!

I optimized this algorithm by making a lot of changes. Now there is less comparisons and less searching. I also modified the GUI example a little to fix everyones confusion they may have.

kuk-bot creator uses this for mm.BOT baal/meph/andy bots on diablo 2

~~ AutoIt v3 Minion ~~Name: Kevin "Aces-X" MorrisOrganization: A C DevelopmentE-Mail: AcesX91@acecoding.netOS: XP Professional; Vista package~~ Released Software ~~CPU-Mach: Topic at acecoding.net ForumsProxyzBuddy: Beta testing at the moment, private onlyWHSTool: Not released to the public

Link to comment
Share on other sites

Another interesting technique exists in finding paths and maybe faster depending of the situation:

Begining : You created a 2 dimensionnal matrix of the field where the start position equals 1, the end position equals -2, every "wall position" is -1 and every "free position" is 0

Main :

Loop through the matrix positions

If you hit the a position wich value is greater than 0 then add the value of the current position + 1 to all the surrounding fields equal to 0

If you hit -1 don't do anything

If you hit -2 check if any surrounding field is greater than 0, if this is true a path has been found, to get the path you just follow the decreasing values until you hit the 1 value

This is a good exercice to practice basic pathfinding, you can even add constraints like sand, mud by adapting the basic algorithm...

Link to comment
Share on other sites

Another interesting technique exists in finding paths and maybe faster depending of the situation:

Begining : You created a 2 dimensionnal matrix of the field where the start position equals 1, the end position equals -2, every "wall position" is -1 and every "free position" is 0

Main :

Loop through the matrix positions

If you hit the a position wich value is greater than 0 then add the value of the current position + 1 to all the surrounding fields equal to 0

If you hit -1 don't do anything

If you hit -2 check if any surrounding field is greater than 0, if this is true a path has been found, to get the path you just follow the decreasing values until you hit the 1 value

This is a good exercice to practice basic pathfinding, you can even add constraints like sand, mud by adapting the basic algorithm...

Is this going to get you the shortest path with the least amount of energy and the least amount of nodes searched? I doubt it from the way you described it. This might work well for none maze like matricies with small amount of nodes to check. Sounds like a good idea though.

www.itoady.com

A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding

Link to comment
Share on other sites

Is this going to get you the shortest path with the least amount of energy and the least amount of nodes searched? I doubt it from the way you described it. This might work well for none maze like matricies with small amount of nodes to check. Sounds like a good idea though.

Yes it finds the fastest path to the maze though in my example it doesnt take the "least energy", we used to study pathfinding and compared the topic way and this way described here... They all had their weak & strong points... I will try to post the autoit code to my algo so you can compare/understand it

Link to comment
Share on other sites

Yes it finds the fastest path to the maze though in my example it doesnt take the "least energy", we used to study pathfinding and compared the topic way and this way described here... They all had their weak & strong points... I will try to post the autoit code to my algo so you can compare/understand it

k sounds cool

www.itoady.com

A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding

Link to comment
Share on other sites

UPDATE

Added option to make the bot move diagonal if needed. The bot will not cut around corners, the bot moves in a smooth more human-like manor.

Searching nodes is animated now. You can see how the bot searches for the path node by node.

www.itoady.com

A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding

Link to comment
Share on other sites

I love what you have done with this!! Great Work!!

I have to admit iwe not read the souce and dont know how you work out you'r "magic", but i still wounder how you determine the path, do you use connections, or do you use hinders ?

Edited by jokke
UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.
Link to comment
Share on other sites

nicely done Toady... I remember studying A* when I was in college, you've optimized it quite nicely!

Now I'm just waiting to hear of someone becoming a programming prof at a university teaching AutoIt :rambo: Your example will be something like chapter 15, "A* searching and AutoIt" :rolleyes:

Shoot, I'd teach it, anyone want to pay my tenure? :x

Link to comment
Share on other sites

Found a little flaw.

When searching for a path down a column, it skips a row each time, meaning when there's a path it could take, it skips over it

Posted Image

The first takes 28 nodes, second only 26 on a path the first could have taken.

That is, it's a flaw if the objective of the program is to find the absolute shortest path to the goal.

Edited by idusy
Link to comment
Share on other sites

I love what you have done with this!! Great Work!!

I have to admit iwe not read the souce and dont know how you work out you'r "magic", but i still wounder how you determine the path, do you use connections, or do you use hinders ?

As the search progresses each node points back to its parent node. The node with the lowest F cost is chosen to be the the current node.

F = G + H

where G is the cost of the path from the starting node to the current node. Each node has its own weight to be added to G, a blank space has a weight of 1, sand = 2, water = 3, and hill = 4. So trying to walk across a hill is like walking 5 moves. Thats why the bot will find it easier to just go around the hill.

H is the heuristic cost from the current node to the goal node. Two H heuristics can be selected, one is Manhattan and the other is Euclidean. Manhattan will cause the path to be in a L shape while Euclidean causes the path to be in a zigzag.

Edited by Toady

www.itoady.com

A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding

Link to comment
Share on other sites

Some pointers:

Overestimating Heuristic Cost:

Using a heuristic that routinely overestimates (the distance cost) by a little usually results in faster searches with reasonable paths.

If making the world bigger you could decouple the path finding data from the search space.

This would reduce memory consumption.

#)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...