2011Scape / game

An open-source emulator that targets RuneTek-5, client revision 667 (October 4th, 2011)
http://2011scape.com
Apache License 2.0
32 stars 131 forks source link

RSMod 2 Pathfinding 5.0 Implementation #530

Closed HarleyGilpin closed 3 months ago

HarleyGilpin commented 3 months ago

What has been done?

What needs to be done?

Example

class PathFinderExample(collisionFlags: CollisionFlagMap) {

    private val pathFinder = PathFinder(collisionFlags)

    fun findPath(level: Int, srcX: Int, srcZ: Int, destX: Int, destZ: Int): Route {
        return pathFinder.findPath(
            level = level,
            srcX = srcX,
            srcZ = srcZ,
            destX = destX,
            destZ = destZ
        )
    }
}

CollisionFlagMap is responsible for storing collision flag data for the game map. When loading map data on the game-server, each object - and special tiles, such as roofs and bridges - should call the helper functions: fun CollisionFlagMap.add(x: Int, z: Int, level: Int, mask: Int) and fun CollisionFlagMap.remove(x: Int, z: Int, level: Int, mask: Int) in order to add or remove, respectively, the mask flag data.

Performance

Benchmark sources: [gg/rsmod/game/pathfinder/benchmarks/][benchmark]

Machine Specs

PathFinder (BFS)

Benchmark                                 Mode  Cnt    Score   Error  Units
GameClickAltPath.sequentialPathFinder     avgt       733.039          ms/op
GameClickLongPath.sequentialPathFinder    avgt       367.350          ms/op
GameClickMedPath.sequentialPathFinder     avgt       310.479          ms/op
GameClickShortPath.sequentialPathFinder   avgt         7.429          ms/op

GameClickAltPath.threadLocalPathFinder    avgt       168.779          ms/op
GameClickLongPath.threadLocalPathFinder   avgt        85.639          ms/op
GameClickMedPath.threadLocalPathFinder    avgt        80.181          ms/op
GameClickShortPath.threadLocalPathFinder  avgt        19.010          ms/op

Glossary

Credits