Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: SMS Pathfinding code

  1. #11
    PGD Staff / News Reporter phibermon's Avatar
    Join Date
    Sep 2009
    Location
    England
    Posts
    524
    Quote Originally Posted by SilverWarior View Post
    As far as frogs go. They have extremely powerful smelling capability. In fact it is so powerful that they can detect increased moisture in the air. So when wind blows over your pond the air is moisturized and then carried away. Frogs can then follow this trail of moisturized air back to your pond. And they can do this from a range of even up to 10 km or 6 miles.
    And frogs are not the only animals capable of this. My mom was born in a village which was founded about 300 years ago when during the drought season pigs (which also have very acute smell) wandered over 15 km (roughly 10 miles) to a fresh water spring which was the only natural spring that season that hasn't dried. In fact from the time of when this spring was discovered for the first tim and till today nobody has ever seen it dry up yet.

    Any way if you look at all the different way animals use for path-finding. Well let us just say that in your lifetime you probably won't be able to write algorithms that mimic most of them.
    Here are just some of the most amazing ways animals use for orientation and path-finding:
    1. Birds are known for being able to detect earth magnetic field and thus location of earths magnetic poles. This allows them to navigate great distances without much problems. But scientists are warning us that with all the electromagnetic interference we are causing we might be eventually causing them havoc in their navigation. And birds are not the only animals that have this ability. Many others have but are not so dependent on it like the birds are.
    2. Bees remember the path they took from their hive to the flower by simply remembering how long they flew in straight lien and when they turned and into which way. They also have a clever way of communicating this information to other bees through so called "bee dance".
    3. Ants always leave chemical trail behind them so they can always return back to the nest. Even ore by manipulating the chemical they use on this trail they are leaving specific message of what kind od destination does this path leaves to (food, danger, etc).

    Sorry for going a bit off-topic but for me this is interesting stuff especially when I see computers trying to mimic/simulate it.
    Ahh! thanks for the info - I didn't know much of that. Oh well it's not off topic really - many great advancements in robotics and AI have come from mimicry of the animal kingdom. The 'flow field' biasing I described seems to my mind to be an analogue of ants leaving scents - perhaps there's something useful in the bee technique?

    For example instead of storing entire paths between points - you could just store the distance travelled by an entity between those two points - then when pathing to that point - compare the linear distance to the distance travelled and if it's greater than you know that there's obstacles between the start and end points. I don't know how that can be useful exactly - but perhaps store the distance travelled and a series of left/right indicators - then when the entity encounters an obstacle it pops a left/right off the stack and knows which way to turn.

    To my mind it would result in an effective path followed between two points across a static terrain but with far less memory used to store that path.

    it would also plug nicely into a steering algorithm. Just a thought experiment but an interesting one!
    When the moon hits your eye like a big pizza pie - that's an extinction level impact event.

  2. #12
    Quote Originally Posted by phibermon View Post
    For example instead of storing entire paths between points - you could just store the distance travelled by an entity between those two points - then when pathing to that point - compare the linear distance to the distance travelled and if it's greater than you know that there's obstacles between the start and end points.
    That reminds me of heuristic path-finding algorithms where you store known traveling distances between different neighboring key/pivot points on tem map.

  3. #13
    I think the subject is better discussed on an evolutionary biology forum or some such place
    I mean, ape what mother nature does and use similar hacks.

    1. Cache it! If a
    NPC finds a route between two points once, it memorizes it and then re-uses it without invoking pathfinding, using simple right/left hand algorithm to go around mobile obstacles. Only large deviation/delay to follow the route causes the actor to reset its cache and perform pathfinding again
    Each NPC has a weighed route cache. Or all units of the same type do, in case of RTS.

    2. Lazy pathfinding
    Use direct movement towards the goal with right/left hand obstacle avoidance first, fill a request for the pathfinding manager that may fulfill it several ticks later
    This evens out CPU load.

    3. If a crowd of adjacent NPCS searches for a path to the same target, do it once. Select the closest NPC as the leader and make all others follow him. Use pathfinding again only if some NPCs have little progress.

    4. Use a crude approximation first, before invoking A*:
    - cast a virtual collider on a direct route to target using left|right hand to go around obstacles
    - if it does reach the target, try smoothing the path out by casting virual colliders between points of the path 10..15 mob diameters apart.
    - if it doesn't, use A*
    You can even make a *tree* of paths, branching every time your collider collides with a new obstacle, one goes left other goes right.

    I mean, I used pretty dumb mechanics in my 1998 FPS but it worked surprisingly well. I'll try describing what I did:

    1. Levels were object soup, up to two thousand cylindrical colliders placed haphazardly on a flat plain sorted into a primitive grid to reduce the O^N. Buildings were made of sprites, physically the same cylindrical colliders

    2. There was manually created graph of nav-zones to allow navigating bridges and other difficult places. The nav-zones wre cylindrical, of different width (often quite wide)

    3. There was nothing like A*. Monsters periodically performed passability checks to see if they can reach their target directly. It was a costly operation consisting of casting a virtual collider along direct path, simulating all drops from ledges and checking for deadly hazards like water or lava. Only one monster per physics tick could do this.

    4. All MOBs kept track of the last nav-zone they visited which was used to find path to target. The algorithm was simple:
    Is my last visited nav-zone the same as as the target?
    YES: move towards the target using left/right hand obstacle avoidance when colliding with something
    NO: find path through the nav-zones graph, set the next nav-zone as my next destination.

    Coupled with 3, this proved to be amazingly efficient. Monsters only had problems with crudely made stairs where I, the player, had to jump to get unstuck, or with narrow bridges, congesting them and slowing to a crawl.
    Other than that... They surely proved to be more proactive than DooM monsters. See player? Go a roundabout way crossing two bridges over a river and then !surprise! him. Silly player, hiding in a hut. Left/right hand along the walls until entrance, oh there is no wall... Surprise!
    They were, in fact, very good at appearing !suddenly! as if from nowhere.

    All of that with a dozen or so nav-zones placed by hand.

    I suppose in modern times your tools auto-build a sparse nav-mesh for your level in offline mode.
    But do not discard the left/right hand. It's a powerful tool.
    Last edited by Chebmaster; 17-08-2017 at 07:00 AM.

  4. #14
    You call that dumb?
    What you used is actually a heuristics path-finding algorithm. The only difference between yours and those found today is that you created higher heuristic level (nav-zones) manually while in todays heuristic path-finding algorithms these higher heuristics levers are created automatically using various algorithms.
    So don't call your path-finding algorithm dumb mechanics because it is quite advanced path-finding algorithm.

    Now you might think: But wait it seems so easy to understand.
    Of course it is easy to understand. Why? Because you are using it every day in your life.

  5. #15
    PGDCE Developer Carver413's Avatar
    Join Date
    Jun 2010
    Location
    Spokane,WA,Usa
    Posts
    206
    I am using a modified flood fill design at the moment,it works in 6 directions since I'm working with hex map designs at the moment. I don't know how this stacks up against the A* in general but for rts/rpg type games where you have to plot a course for multiple targets for multiple rpc's I think this method could really shine. unlike A* this routine starts at the target and floods out posibly hitting multiple npc's depending on that distance set for the target, multi targets can be plotted at the same time and shortest distance will overwrite any overlaps.So for gather's of food a single map could be generated for all the npc's in a group and would remain valid until a food source runs out. a return map would be required for unloading of course but it would remain valid until all resources in the area have been depleted.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •