SFTtech / openage

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

Invalidate flow field cache entry when cost field changes #1679

Open heinezen opened 2 months ago

heinezen commented 2 months ago

Required Skills: C++

Difficulty: Easy

The openage pathfinder uses flow fields to search for a path on the pathfinding grids (please read the documentation to familiarize yourself with the concepts). To avoid unnecessary computations, fields are cached and reused for similar paths.

Currently, flow fields in the cache never get invalidated or updated when the costs of cells on the grid change, so these changes are never reflected in path requests when using the cached fields. This also means that dynamic changes to the grid are also not possible at the moment which is a huge downsight. A dynamic grid is required for a lot of gameplay features (e.g. placing buildings, change in terrain), so cache invalidation should be implement as soon as possible.

The easiest way to address this issue is to mark sectors/cost fields that have changed as "dirty" and then evict and recompute the flow fields for them when a new path is requested.

To try out the current pathfinder, check out pathfinding demo 1 by running the following command:

./run test -d pathfinding.tests.path_demo 1

Tasks:

Further Reading

heinezen commented 2 months ago

Depends on https://github.com/SFTtech/openage/pull/1656

anupriyakkumari commented 1 month ago

Hi, I'd like to take this up.

heinezen commented 1 month ago

@anupriyakkumari Hey, no problem go ahead :)

yukirine commented 1 month ago

Hey, I'd like to help with this too !

heinezen commented 1 month ago

@yukirine I don't think @anupriyakkumari has done anything with the issue yet, so you can just implement it I think ^^

anupriyakkumari commented 1 month ago

Hi, yes. I've been busy and haven't had the time to work on this just yet. Someone else can surely take it up.