I need to improve my A* algorithm
Not speedwise, but intelligencewise. I have several enemies who''s target is player 1. The problem is that since they''re using the same algorithm to get to the same goal they end up getting the same path and sometimes they look just like one monster as they''re following the routes at the same time.
And also since it''s a bomberman game they need to be aware of bombs and their explosion radius. Should this be included in the A* algorithm or later when the AI tries to follow the route the algorithm found if it encounters a bomb it calls the algorithm again?
You could avoid two enemys ''sticking'' to each other by giving all of them different speeds. Or you could have a different algorithm for each of them. Some could share an almost random moving algorithm (where they move randomly unless they are so near the target that they can get to it, when they move to the target via the shortest path).
I did the above in the pacman game i made. It works fine.
Also, u could give different H values (vary the degree of dominance of the H value over the G value) to A* when it calculates the path for different enemys. This i would probably work (but i am not too sure).
Goodluck!
I did the above in the pacman game i made. It works fine.
Also, u could give different H values (vary the degree of dominance of the H value over the G value) to A* when it calculates the path for different enemys. This i would probably work (but i am not too sure).
Goodluck!
If you''re using a grid based walkspace, the easiest way to stop this, if all the AI''s travel at the same speed, is to mark the square with the distance in grid squares that an AI is from it if that AI is going to traverse it. Then, in subsequent AI A* searchs, if the square is a certain number away (closer OR further, threshold depends on speed of AI), then that AI can traverse it, otherwise reject that square during the A*.
April 28, 2003 04:47 AM
Or you could prevent units from entering the same space by making the areas occupied, or something like that. It makes your game quite different, though, of course.
In my humble opinion, you should add a little bit of randomness to your solution. When your enemies pick a path, give them a % chance of picking a given path. A quick little genetic algorithm could prove sufficient here; just evolve it for about, say, a dozen generations and use that to pick a path. The fitness would be measured against just how "good" a given move is.
For instance, if the enemy is about to move right into the radius of an explosion to the south, but has a clear space to the east, the chance of picking "east" would be much greater, but the possibility that, in a fit of confusion, it''d go south and get wiped out, is still not 100% impossible. Although it would be quite low.
For instance, if the enemy is about to move right into the radius of an explosion to the south, but has a clear space to the east, the chance of picking "east" would be much greater, but the possibility that, in a fit of confusion, it''d go south and get wiped out, is still not 100% impossible. Although it would be quite low.
My Website: ai-junkie.com | My Books: 'Programming Game AI by Example' & 'AI Techniques for Game Programming'
May 03, 2003 06:08 PM
A simple thing you could do is to add a bit to the cost of traversing a node, if it is close to another monster.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement