nanodeath / CrowLib

Crow: Find your shortest path!
http://www.effectgames.com/effect/article.psp.html/community/Pathfinding_library_Dijkstra_s_Algorithm
MIT License
40 stars 6 forks source link

Algorithm autoselection #1

Closed nanodeath closed 14 years ago

nanodeath commented 14 years ago

Right now, the way algorithms are chosen is pretty dumb. By default, getNodes uses a linear search algorithm unless you choose BFS explicitly, and findGoal will use Dijkstra's unless you choose A* explicitly. The goal behind writing a pathfinding library such as Crow is to provide a powerful but simple API. In other words, the choosing of an algorithm should be a declarative process, not an imperative one.

Ideally, we'd be looking at something like this (written in plain English):

I want to find the shortest path between point A and point B. It doesn't have to be exact; a reasonable guess is okay. The target isn't expected to move. I want the complete path. Once the path is generated, I'm done -- I don't care if the graph it was built upon changes. -> This would return A*, limit undefined, and be baked (unchangeable; unassociated with graph).

I want to find the shortest path between point A and an unknown node matching condition f(x). It can be a guess. Target doesn't move. Complete path required. Done afterwards. -> This would return Dijkstra's, limit undefined, and be baked.

I want to know if point B is reachable from point A. -> This would either be BFS or A*.

When picking attributes for the algorithm, there should be a number of descriptors available. Some ideas are: MUST_NOT, SHOULD_NOT, MAY, SHOULD, MUST. This way, you can say I want heuristics, but don't have to have them (SHOULD); or I don't really care (MAY), or it has to support moving target optimizations (MUST), etc.

nanodeath commented 14 years ago

This is ongoing, but has been implemented as AlgorithmResolver.