SFTtech / openage

Free (as in freedom) open source clone of the Age of Empires II engine 🚀
http://openage.dev
Other
12.78k stars 1.13k forks source link

New pathfinding and grouping #366

Open zesterer opened 9 years ago

zesterer commented 9 years ago

Presumably you use some form of grid-based A* algorithm? Maybe it is better to 'group' nearby searches to reduce the stress of re-calculating paths that are very similar.

zesterer commented 9 years ago

I recommend you try out a game called 'Liquid War'. It's FOSS, and is in most mainstream distro repositories. It involves a game where you control this pathfinding fluid (composed of tens of thousands of entities) that move towards the cursor, avoiding obstacles. Perhaps this would be a good bit of inspiration? Liquid War does it all at 60 fps, and often with very high resolution grids, so perhaps taking a peek within it's source code might be worthwhile?

TheJJ commented 9 years ago

Never heard of it, but it looks cool and has probably nice inspiration for some areas.

Jon0 commented 9 years ago

Having a few modular path finding systems would be interesting, while having one path finding system as close to the original is good, it would be cool having many options like these newer techniques, which may considerably affect gameplay / balance

TheJJ commented 9 years ago

The thing most complained about by aoe2 players i think is pathfinding bugs and especially blockages. So i guess we can try doing something awesome and wait for feedback. Imagine your huge armies just flowing through each other naturally without blocking :cake:

-> Basically we'll create a multi-layer navigation system, using ideas from all those (awesome) papers:

Especially the "believable crowds" paper seems to be promising in combination with the "crowd pathfinding using flow fields" chunk navigation paper.

If this works and performs, it's probably the best RTS pathfinder ever.

If anyone wants to implement any of these ideas, go for it.

zesterer commented 9 years ago

I think it's important with large groups with the same goal to preserve some kind of locality and flocking behaviour. If they are unable to share data among one-another, substantial optimisation will be impossible.

TheJJ commented 8 years ago

http://www.gameaipro.com/GameAIPro/GameAIPro_Chapter23_Crowd_Pathfinding_and_Steering_Using_Flow_Field_Tiles.pdf

This is more or less the implementation design I was trying to come up with, but with awesome portals between the chunks. It's probably what we want! The portal-navigation can still be done with jump point search or D*-lite, in the description they use plain A*.

some other example: https://vonwolfehaus.github.io/flow-field/

the gameaipro-thing seems to be based on (although it doesn't cite them):

coffenbacher commented 8 years ago

Awesome paper. I'm excited for pathfinding in openage... it could easily be the "killer app" for eventually getting aoe2 players to switch. It's one of a handful of things that can be a massive improvement while staying totally true to the original gameplay (especially compared to HD, which had some big pathfinding regressions).

elnabo commented 8 years ago

A hierarchical solution seems to be a good idea. However, I wonder how the gameai paper handle an heterogeneous crowd with different speeds.

TheJJ commented 8 years ago

(this post is subject to change because of adding new ideas or detecting problems)

So in a simplified explanation:

Wandalen commented 7 years ago

Good problem for GPU.

heinezen commented 7 years ago

i'll just add the thoughts about formation pathfinding from #705 here:

This should compute faster than doing pathfinding across long distances for every single unit in a selection.

TheJJ commented 6 years ago

https://web.archive.org/web/20200414093657/https://www.blog.drewcutchins.com/blog/2018-8-16-flocking

(Updated link with web-archived one)

simonsan commented 5 years ago

http://web.archive.org/web/20190803092008/https://richg42.blogspot.com/2018/02/on-age-des-pathingmovement.html?m=1

TomJansen commented 4 years ago

This hackernews thread could be interesting: https://web.archive.org/web/20200414093542/https://news.ycombinator.com/item?id=22848106

(Updated link with web-archived one)

zesterer commented 4 years ago

I'd recommend not throwing the baby out with the bathwater. A can be very* fast if you throw enough good information at the heuristic function. There's absolutely no need to stick with distance(pos, tgt).

One solution I've seen before is a "heirarchical" pathfinding technique where the world is split into progressively largely chunks, where each chunk is either "empty" or "non-trivial" (i.e: the algorithm needs to walk down the heirarchy into lower-down chunks to figure out whether it's possible to path through it). Over long distances and with large maps with frequent open spaces as is common in an AoE game, this could be extremely fast.

Take a look at this article for how something similar was implemented for massive Factorio maps: https://web.archive.org/web/20200415175445/https://factorio.com/blog/post/fff-317

TheJJ commented 4 years ago

Thanks for the links and ideas :) The concrete plan for our pathfinding is definitely not cut in stone. We have all options and I'd go for a extensible, step-by-step solution. This pretty much depends on how we store the map state, and that is something (among the game simulation itself) that we have to resolve first (i.e. in #1066, I'm on it :D).

The factorio hierarchical pathfinding sounds very promising for the large-scale search, what we have to resolve then is the formation/local avoidance behavior between units. What approach is best there, I can't tell yet.

sandsmark commented 4 years ago

Ref liquid war: The algorithm is described here, though I'm not sure at least I'd be able to implement it from that description alone: https://github.com/bkil/liquid-war-5/blob/master/doc/xml/algorithm.xml

I think this is the interesting part of the algorithm: https://github.com/bkil/liquid-war-5/blob/master/src/spread.s

It's in fairly straightforward assembly, and fortunately it's documented. Unfortunately in french (I don't know french).

As for other (aoe1/2-clone) implementations:

In general, trying to make it both look good (there's a very limited number of angles after all), feels good, and is efficient is hard. Throw in unit formations, minimum attack distances, gates (messes with caching/reuse), fog of war, etc. and it gets even more complex.

(As for a bit more far-out ideas I remember seeing some paper about efficient path finding using something that kind of reminded me of the original aoe2 pathfinding from IIIM. I'll post it if I find it again.)

edit: oh, and for the factorio stuff, that kind of looks like the original aoe2 pathfinding, I think? one high-level tile pathfinder used for long distance discovery, and a low-level one for the smaller parts.