Document Pathfinding

  • The function hints that there is a default cost matrix used if I don't specify one.

    I would like to know what it is.

    For instance, does it include my buildings? Creeps?

  • Wouldn't hurt if someone wanted to document a bit more though.

    Does it always return a path if one exists?

    It would also be cool if had an option to use findRoute first for broadphase, since the 16 max room limit is low for some searches.

    Also it would be helpful if gave me a reason why my path find fails when it returns an incomplete path. Did it hit maxRooms? maxOps? Are there other reasons it can fail?

    It doesn't really help that all the information I need to know to successfully path from any A to any B is strewn across 4 different places:

    • (seems to always find the room route from A to B )
    • (works for 98% of A to Bs, but that last 2% is a pain and no help in the docs for that)
    • CostMatrix (sometimes breaks the above if you don't know what the defaults are)
    • Room.findPath (seems to have 98% overlap with with some extra options. Is it a functional superset of Can't tell. Does it matter which room instance I use? Seems like this wants to be a static method like, since it's not I'm left wondering how that is going to effect my code)

    It seems like all this stuff really wants to be in the same place.

  • Culture tends to always work, but it isn't guaranteed.

    PathFinder is the native library for pathfinding. (iirc) The default cost matrix is the same "cost matrix" used by findPath, meaning all objects that can block a creep are max path cost, swamps are more expensive than plain, and roads are 2x cheaper than road.

    If you're building a custom CostMatrix, it's best to do the whole thing yourself than rely on some interleaving between the default matrix and your custom overlay.

    findPath is the old pathfinder built entirely in js. It's good to get started with but not good if you want efficiency.

    A lot of documentation is scattered, typically the best resource is your own experience. If you want a fast and very controllable path, only use PathFinder.