Exploring a map - dijkstra?

Started by
5 comments, last by ToohrVyk 17 years, 1 month ago
hi, im a newbie in game programming (just taking it at uni this year) so please bear with me... im working on a game where the player initially has no idea about the map. so the player has to explore the map and find stuff (Player has limited vision). There are several types of obstacles that he has to get past. Is there a specific kind of algorithm that is suited to 'exploring'? Im currently thinking of dijkstra, but im not sure...Pls advice! Thnx!
Advertisement
If the player, as in human player is exploring the map, what do you need dijkstra for? I'll assume you mean to get AI to explore the map? dijkstra would be fine for that.
Thanks Yes im talking abt da AI player. i dont need a shortest path, and i dont have a specific goal. at this level, i just want da AI player to explore the map as much as he can in limited time.
Take a look at the A* (pronounced A-star) algorithm. That's used for pathfinding.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
If you have nowhere in particular that you're trying to get to then breadth first search or depth first search should be fine. If you're trying to get somewhere then you might want to look at A*.
If your searching the map for a certain type of object, and you don't know where the closest object of that type is on the map - use Dijkstra and terminate it when an object of the correct type is found.
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
A possibility is to set individual units to "explore" tasks. Then, the unit would examine adjacent tiles and determine which movement would reveal the highest amount of terrain (that is, it would move directly into uncharted territory). If no adjacent tile would reveal terrain, I would suggest finding the nearest unrevealed tile and moving straight to that tile. An additional constraint that would be useful is to only consider accessible unrevealed tiles only (both when examining adjacent tile revealing power and new destinations), so units don't spend time exploring areas that cannot be reached yet, and neither do they try to get to them.

Now, if you have several units exploring at the same time, you don't want them to overlap each other. This would happen naturally if the units are close to each other (the first's exploration would cause the second one to take a new direction), but units in their "move towards new exploration start point" would probably annoy each other (since the closest unexplored point might become explored during transit). I would cause an exploring unit's movement to be interrupted if another unit explores its destination tile, thus prompting the stopped unit to compute a new path, possibly to a new area.

This topic is closed to new replies.

Advertisement