{"id":25940709,"url":"https://github.com/2003scape/rsc-path-finder","last_synced_at":"2025-03-04T05:18:36.166Z","repository":{"id":36943460,"uuid":"232441780","full_name":"2003scape/rsc-path-finder","owner":"2003scape","description":"👣 generate paths between points on a runescape classic map","archived":false,"fork":false,"pushed_at":"2022-03-26T00:16:38.000Z","size":702,"stargazers_count":5,"open_issues_count":3,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-19T22:17:12.526Z","etag":null,"topics":["astar","collision-detection","javascript-game","landscape","maps","pathfinder","pathfinding","rsc","runescape","tile"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/2003scape.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-08T00:12:15.000Z","updated_at":"2023-04-27T02:26:19.000Z","dependencies_parsed_at":"2022-08-08T18:30:39.504Z","dependency_job_id":null,"html_url":"https://github.com/2003scape/rsc-path-finder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2003scape%2Frsc-path-finder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2003scape%2Frsc-path-finder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2003scape%2Frsc-path-finder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/2003scape%2Frsc-path-finder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/2003scape","download_url":"https://codeload.github.com/2003scape/rsc-path-finder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241787644,"owners_count":20020130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astar","collision-detection","javascript-game","landscape","maps","pathfinder","pathfinding","rsc","runescape","tile"],"created_at":"2025-03-04T05:18:35.728Z","updated_at":"2025-03-04T05:18:36.156Z","avatar_url":"https://github.com/2003scape.png","language":"JavaScript","readme":"# rsc-path-finder\ngenerate paths between points on a runescape classic map. each tile is\nexpanded into a 2x2 grid of booleans describing how the tile is blocked. this\nallows for horizontal, vertical and fully-blocked tile representation\n(diagonal walls are completely impassbale). once a path is found, the steps are\nsmoothed and converted to game coordinates.\n\nthis module is safe to use in a game loop as the computation is asynchronous.\n\n![](./doc/legends-path.png?raw=true)\n\n*path from Lumbridge to the Legend's Guild*\n\n![](./doc/bandit-path.png?raw=true)\n\n*path from Al Kharid to Bandit Camp*\n\n![](./doc/gnome-path.png?raw=true)\n\n*path to Tree Gnome Village entrance*\n\n\n## install\n\n    $ npm install @2003scape/rsc-path-finder\n\n## example\n```javascript\nconst fs = require('fs');\nconst { gunzipSync } = require('zlib');\nconst { Config } = require('@2003scape/rsc-config');\nconst { Landscape } = require('@2003scape/rsc-landscape');\nconst { PathFinder } = require('./src');\n\nconst config = new Config();\nconfig.loadArchive(fs.readFileSync('./config85.jag'));\n\nconst landscape = new Landscape();\nlandscape.loadJag(fs.readFileSync('./land63.jag'),\n    fs.readFileSync('./maps63.jag'));\nlandscape.loadMem(fs.readFileSync('./land63.mem'),\n    fs.readFileSync('./maps63.mem'));\nlandscape.parseArchives();\n\nconst pathFinder = new PathFinder(config, landscape);\nconst objectLocations =\n    JSON.parse(gunzipSync(fs.readFileSync('./object-locs.json.gz')));\nobjectLocations.forEach(obj =\u003e pathFinder.addObject(obj));\n\nconst wallObjectLocations = require('./wallObject-locs');\nwallObjectLocations.forEach(obj =\u003e pathFinder.addWallObject(obj));\n\n// replace the taverly gate with an open gate\npathFinder.addObject({ id: 58, x: 341, y: 487, direction: 4 });\n\n// close the door in gertrude's house\npathFinder.addWallObject({ id: 2, x: 163, y: 513, direction: 1 });\n// open it again\n// pathFinder.addWallObject({ id: 1, x: 163, y: 513, direction: 1 });\n\npathFinder.start();\n\n(async () =\u003e {\n    const path = await pathFinder.findPath(\n        { x: 126, y: 655 },\n        { x: 513, y: 552 });\n        //{ x: 72, y: 694 },\n        //{ x: 320, y: 290 });\n        //{ x: 672, y: 718 },\n        //{ x: 634, y: 706 });\n        //{ x: 138, y: 1594 },\n        //{ x: 131, y: 1602 });\n    console.log('found path to legends guild', path.length);\n\n    fs.writeFileSync('./legends-path.png',\n        pathFinder.toCanvas(path).toBuffer());\n\n    pathFinder.stop();\n})();\n```\n\n## api\n### pathFinder = new PathFinder(config, landscape, tickRate = 80)\ncreate a new pathfinding instance.\n\n`config` in the first argument must contain definitions of game and wall objects\nwith at least the following:\n\n```javascript\n{\n    // definitions for game objects (tree, altar, furnace, etc.)\n    objects: [\n        {\n            type: 'unblocked' || 'blocked || 'closed-door' || 'open-door',\n            width: Number,\n            height: Number\n        },\n        // ...\n    ],\n    // definitions for wall objects (doors, walls, boundaries, etc.)\n    wallObjects: [\n        {\n            blocked: true || false,\n        }\n        // ...\n    ]\n    // definitions for tiles (floors, water, roads, etc.)\n    tiles: [\n        {\n            blocked: true || false,\n        }\n        // ...\n    ]\n}\n```\n\n[objects](https://github.com/2003scape/rsc-config#configobjects),\n[wallObjects](https://github.com/2003scape/rsc-config#configwallobjects) and\n[tiles](https://github.com/2003scape/rsc-config#configtiles)\nare all members of an\n[rsc-config](https://github.com/2003scape/rsc-config#config--new-config)\ninstance.\n\n`landscape` is an instance of\n[rsc-landscape](https://github.com/2003scape/rsc-landscape#landscape--new-landscape).\n\n`tickRate` is how often (in ms) to poll for new paths to find when `findPath`\nisn't active.\n\n### pathFinder.addObject({ id, x, y, direction })\nadd game object to position. `id` corresponds to index in `config.objects`. if\n`open-door` or `closed-door` type objects are added, replace them with door\nwall objects.\n\n### pathFinder.addWallObject({ id, x, y, direction })\nadd wall object to position. `id` corresponds to index in `config.wallObjects`\narray. if an unblocked wall object is added, remove any existing obstacles\n(door with doorframes, spider web with blank, etc.).\n\n### pathFinder.start()\n### pathFinder.stop()\nenable and disable the pathfinding run loop.\n\n### async pathFinder.findPath({ x, y }, { x, y })\nfind a path between startPos and endPos. returns an array of game coordinates.\n\n### pathFinder.isValidGameStep({ x, y }, { deltaX, deltaY })\nreturn true if we can step from startPos in the step direction.\n\n### pathFinder.getLineOfSight({ x, y }, { x, y })\nfind a direct diagonal beeline path between two points.\n\n### pathFinder.toCanvas(path = undefined)\ncreate a canvas with all of the obstacles filled in with white. if path is\nspecified, fill the path tiles with red.\n\n## license\nCopyright 2020  2003Scape Team\n\nThis program is free software: you can redistribute it and/or modify it under\nthe terms of the GNU Affero General Public License as published by the\nFree Software Foundation, either version 3 of the License, or (at your option)\nany later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A\nPARTICULAR PURPOSE. See the GNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License along\nwith this program. If not, see http://www.gnu.org/licenses/.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2003scape%2Frsc-path-finder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F2003scape%2Frsc-path-finder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F2003scape%2Frsc-path-finder/lists"}