Live data from Hacker News

Ask HN: Have you ever seen a pathfinding algorithm of this type?

blog.breathingworld.com

71–77 of 77 posts

Re: Ask HN: Have you ever seen a pathfinding algorithm of this type?

#71
post #45

Earlier quoted context omitted.

Sure, if you held a deadline to my head and told me to do it, I'd just include obstacles that are "within their memory". Expire them by time, refresh them by range (can see as they move). Constantly replan and I bet you'd get something reasonable looking, but _only_ if you add an obstacle that represents only what the creature can see. If you add the whole obstacle (regardless of what it can see), it'll just do the o…

Oh! This is it! This is exactly why I wanted to create a new algorithm!

If you want something that looks a little "more real" but doesn't involve complex management of memory, maybe try a bug algorithm. https://en.wikipedia.org/wiki/Bug_algorithm

It errs on the side of "stupid" but is much easier to implement.

Re: Ask HN: Have you ever seen a pathfinding algorithm of this type?

#72
post #45

Earlier quoted context omitted.

Oh! This is it! This is exactly why I wanted to create a new algorithm!

If you want something that looks a little "more real" but doesn't involve complex management of memory, maybe try a bug algorithm. https://en.wikipedia.org/wiki/Bug_algorithm It errs on the side of "stupid" but is much easier to implement.

Oh~ This is very similar to the concept I was thinking of. I don't really like the idea of exploring strictly in a clockwise direction, though. Thank you for the information!

Re: Ask HN: Have you ever seen a pathfinding algorithm of this type?

#73
post #67
post #29

So far, no one has mentioned "Bug Algorithms", which have a similar structure of (1) walk in the direction of the goal, (2) walk around obstacles as they are encountered, (3) leave the obstacle to proceed when some condition is met. They are very simple to implement (though not optimal) and there are a number of variants to play around with. Howie Choset has some good lecture slides that describe them [1]. However, a…

I've done that something like that.[1] It's appropriate where there's a significant cost to detecting obstacles, because it tests few unnecessary cells. It heads to the goal until an obstacle is reached, then follows the wall. Unusually, it forks and follows both the left and right wall simultaneously. It's not always optimal, but the optimal algorithms such as A* have to test more cells. This algorithm runs my NPCs…

Oh, thank you. I'll have to take a look at the source code as well.

Re: Ask HN: Have you ever seen a pathfinding algorithm of this type?

#74

Earlier quoted context omitted.

On a sparse map, you can tune A* all day, but ultimately if your paths involve more than 1) vertices on the obstacles or 2) straight lines from src to (maybe some of) those vertices to goal, you have created suboptimal paths. The idea goes: Best to just search in that space vs iterating over some other space attempting to indirectly coax out the optimal path. The bonus is that VG-based search is very fast b/c it does…

> On a sparse map, you can tune A* all day, but ultimately if your paths involve more than 1) vertices on the obstacles or 2) straight lines from src to (maybe some of) those vertices to goal, you have created suboptimal paths. You would still be choosing a node with the best f-value, so you'll get optimal solutions with any admissible heuristic. In a 2D-grid your heuristic should also be consistent, which will resul…

I don't think we're disagreeing

Re: Ask HN: Have you ever seen a pathfinding algorithm of this type?

#75
post #57
post #39

Very similar to the pathfinder I wrote for Ultima in 1990. At the time I was too young and naive to know that there were lots of existing similar graph algorithms (this was before the internet and, more importantly, I was 20 years old and therefore already knew everything LOL). One nice thing we added to those "large" game worlds back then was to pre-compute "highway" routes and then path-find at run-time to a nearby…

Wow~ You’re one of the developers of Ultima, a game I truly loved! The concept of using "highways" is really fascinating! However, in my project, everything is in plain view for everyone to observe, so I won’t be able to use any cheats like that!

Yes. I worked on Ultima 7, 8 and Online (but only on UO in early stages as a manager to help get it started). Glad you enjoyed them. I think I still have box copies around here somewhere.

The pathfinding was a pretty expensive part of the game. I don't remember the profiling details of course (it was 25 years ago) but I do remember us being concerned about it. If I remember correctly we ended-up spreading out the computational load over multiple frames since the P.F. cost is obviously very bursty. I vaguely recall refactoring it to make it stateful so that we could spread the computational cost over X frames. Because pathfinding and follow code were the very first things I worked on for those games I had to write a sandbox because there was no game environment to work in yet.

I also remember that we added more and more "optimization" hacks to the pathfinder because of the cost. The discussion was like: "Its taking too long when the NPCs go upstairs and they end up lost in the bedrooms by the timeout" and so we'd add hacks like "Exclude staircases". There were a number of these hacks. Each of those hacks would then create non-obvious complications and I strongly remember a lot of frustrating time chasing bug reports of the "bad pathfind in case X" variety only to discover that it was working exactly as designed and that the real problem was one of these hacks had unexpected consequences like: "We excluded to staircase but the staircase tiles extend in front of the door so now they can't find their way out."

This is a tangent to your question about pathfinding, but while I'm thinking about it ... a lesson from U7 pathfinding (and animation in general) was that the stateful requirements were common enough that by U8 I built a Domain Specific Language to model/handle it. The language I built (called Unk) and its compiler had closure concepts very similar to what I later discovered was called "async/await" semantics. This DSL made the game designers life a lot easier -- remember other than those Unk scripts everything was in C and assembly, ie no garbage collectors. Again, I was too young and naive (pre-internet!) to know that async-like language concepts already existed so I just naively "invented" it all from scratch.

Re: Ask HN: Have you ever seen a pathfinding algorithm of this type?

#76
post #17

Earlier quoted context omitted.

Unless the "outline" is like tensing a rubber band around the object. In that case, the collision would happen outside the convex part. Anyway, the details are not enough for me to fully grasp the algo described.

You're referring to the "Convex Hull". And if you are inside a shape, drawing edges to the visibile vertices of the shape (until you're on the boundary of the convex hull) will easily get you a path out, and, bonus, will eventually draw a perfect shortest path to the end. See: https://news.ycombinator.com/item?id=42608107#42626311

Yeah, thank you! I couldn't find the right term.

Re: Ask HN: Have you ever seen a pathfinding algorithm of this type?

#77
post #75
post #57

Earlier quoted context omitted.

Wow~ You’re one of the developers of Ultima, a game I truly loved! The concept of using "highways" is really fascinating! However, in my project, everything is in plain view for everyone to observe, so I won’t be able to use any cheats like that!

Yes. I worked on Ultima 7, 8 and Online (but only on UO in early stages as a manager to help get it started). Glad you enjoyed them. I think I still have box copies around here somewhere. The pathfinding was a pretty expensive part of the game. I don't remember the profiling details of course (it was 25 years ago) but I do remember us being concerned about it. If I remember correctly we ended-up spreading out the com…

Yes, I was a huge fan of Ultima 7, 9 and Online. I remember that incredible sense of freedom gave me a kind of liberation(?). It’s an honor to be able to have this conversation with you. Thinking about how you were already grappling with pathfinding issues and addressing them in real-time back then makes me feel a bit envious. I’m sure there weren’t many people who could have had such experiences at that time. It’s thanks to people like you with those experiences that today’s programming languages and skills have developed as they have. My technical level is far below yours, but I want to complete a lightweight pathfinding algorithm for my project, no matter what. Thank you for sharing such an inspiring story.
Post reply on HN