{"id":16253017,"url":"https://github.com/digitsensitive/astar-typescript","last_synced_at":"2025-04-13T05:32:51.833Z","repository":{"id":21753769,"uuid":"91873110","full_name":"digitsensitive/astar-typescript","owner":"digitsensitive","description":"A* search algorithm in TypeScript","archived":false,"fork":false,"pushed_at":"2023-04-26T21:58:07.000Z","size":1464,"stargazers_count":95,"open_issues_count":9,"forks_count":19,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T09:18:09.564Z","etag":null,"topics":["a-star","a-star-path-finding","a-star-search","astar","astar-typescript","game","path-finding","pathfinding","search-algorithm","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digitsensitive.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://www.buymeacoffee.com/JZDVjsT26"]}},"created_at":"2017-05-20T07:34:50.000Z","updated_at":"2025-02-21T10:18:31.000Z","dependencies_parsed_at":"2024-06-18T18:21:27.086Z","dependency_job_id":null,"html_url":"https://github.com/digitsensitive/astar-typescript","commit_stats":{"total_commits":113,"total_committers":4,"mean_commits":28.25,"dds":0.1504424778761062,"last_synced_commit":"d598cec542b7cc06b5bb40c71d8701c5221e40ed"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitsensitive%2Fastar-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitsensitive%2Fastar-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitsensitive%2Fastar-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitsensitive%2Fastar-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitsensitive","download_url":"https://codeload.github.com/digitsensitive/astar-typescript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670512,"owners_count":21142896,"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":["a-star","a-star-path-finding","a-star-search","astar","astar-typescript","game","path-finding","pathfinding","search-algorithm","typescript"],"created_at":"2024-10-10T15:15:40.974Z","updated_at":"2025-04-13T05:32:51.788Z","avatar_url":"https://github.com/digitsensitive.png","language":"TypeScript","readme":"# AStar-Typescript\n\n[![GitHub Stars](https://img.shields.io/github/stars/digitsensitive/astar-typescript?style=flat-square)](https://github.com/digitsensitive/astar-typescript/stargazers) [![GitHub Forks](https://img.shields.io/github/forks/digitsensitive/astar-typescript?style=flat-square)](https://github.com/digitsensitive/astar-typescript/network/members) [![GitHub Issues](https://img.shields.io/github/issues/digitsensitive/astar-typescript?style=flat-square)](https://github.com/digitsensitive/astar-typescript/issues) [![Current Version](https://img.shields.io/npm/v/astar-typescript?style=flat-square)](https://www.npmjs.com/package/astar-typescript)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=100% src=\"astar_logo.png\"\u003e\n\u003c/p\u003e\n\n#### The A-star search algorithm library in TypeScript\n\nAStar-TypeScript is an A-star pathfinding API written in TypeScript to use for your HTML5 games or other browser-based projects.\n\nThis library was influenced and inspired by [@qioa - PathFinding.js](https://github.com/qiao/PathFinding.js), [@bgrins - javascript-astar](https://github.com/bgrins/javascript-astar), [@prettymuchbryce - easystarjs](https://github.com/prettymuchbryce/easystarjs) and [@redblobgames](https://www.redblobgames.com/pathfinding/a-star/introduction.html).\n\n## Buy me a coffee\n\nWhether you use this project, have learned something from it, or just like it, please consider supporting it by buying me a coffee.\n\n\u003cdiv align=\"center\"\u003e\n\u003ca href=\"https://www.buymeacoffee.com/JZDVjsT26\" target=\"blank\"\u003e\n\u003cimg src=\"https://www.buymeacoffee.com/assets/img/custom_images/black_img.png\" alt=\"Buy Me A Coffee\" style=\"height: auto !important; width: auto !important;\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n## Live example\n\nSelect a folder, navigate to it, and clone this repository\nwith this command-line:\n\n```\ngit clone https://github.com/digitsensitive/astar-typescript.git\n```\n\nInstall the dependencies:\n\n```\nyarn install\n```\n\nRun the live example:\n\n```\nyarn run-example\n```\n\n## Installation\n\n```sh\nyarn add astar-typescript\nnpm install astar-typescript --save\nbower install astar-typescript --save\n```\n\n## Import\n\n### TypeScript\n\n```typescript\nimport { AStarFinder } from 'astar-typescript';\n```\n\n### Javascript\n\n```javascript\nlet AStarFinder = require('astar-typescript');\n```\n\n### AMD\n\n```javascript\ndefine(function (require, exports, module) {\n  let AStarFinder = require('astar-typescript');\n});\n```\n\n## Basic Usage\n\nCreate an astar instance:\n\n```ts\nprivate aStarInstance: AStarFinder;\n```\n\nLoad grid data:\n\nUsing an **array** (hardcoded or from a Tilemap-Editor)\n\n\u003e 0 = walkable\n\u003e 1 = not walkable\n\n```ts\nlet myMatrix = [\n  [0, 0, 0, 0, 0, 0, 0, 0],\n  [0, 0, 0, 0, 0, 0, 0, 1],\n  [0, 0, 1, 1, 0, 1, 1, 0],\n  [0, 0, 1, 0, 0, 0, 1, 0],\n  [0, 0, 0, 0, 0, 0, 1, 0],\n  [1, 1, 1, 0, 1, 0, 1, 0],\n  [0, 0, 0, 0, 1, 0, 1, 0],\n  [0, 0, 1, 0, 0, 0, 0, 0]\n];\n\nthis.aStarInstance = new AStarFinder({\n  grid: {\n    matrix: myMatrix\n  }\n});\n```\n\nor randomly generated array **from width and height**\n\n```ts\nthis.aStarInstance = new AStarFinder({\n  grid: {\n    width: 8,\n    height: 8\n  }\n});\n```\n\nGet the path:\n\n```ts\nlet startPos = { x: 0, y: 0 };\nlet goalPos = { x: 4, y: 5 };\n\nlet myPathway = this.aStarInstance.findPath(startPos, goalPos);\n```\n\n## Advanced Usage\n\nAdditional parameters may be passed to adapt your finder.\n\n### Diagonal movements\n\nIf you want to disable `diagonal movements`:\n\n```ts\nthis.aStarInstance = new AStarFinder({\n  grid: {\n    width: 8,\n    height: 8\n  },\n  diagonalAllowed: false\n});\n```\n\n### Heuristic function\n\nSet the `heuristic function` (Manhattan, Euclidean, Chebyshev or Octile):\n\n```ts\nthis.aStarInstance = new AStarFinder({\n  grid: {\n    width: 8,\n    height: 8\n  },\n  heuristic: 'Manhattan'\n});\n```\n\nIt is possible to adjust the `weight` of the heuristic function.\nFor example if you use 0, every heuristic function will return zero.\nThat is how you can turn A* into Dijkstra’s Algorithm.\nDepending on the `weight` value you can decide if you prefer speed or accuracy.\nThe lower the `weight` is, the lower will the heuristic function get, which will\nmake the A* slower.\n\n```ts\nthis.aStarInstance = new AStarFinder({\n  grid: {\n    width: 8,\n    height: 8\n  },\n  weight: 0.7\n});\n```\n\n### Start and End Node\n\nInclude or Exclude the `start and end node`:\n\n```ts\nthis.aStarInstance = new AStarFinder({\n  grid: {\n    width: 8,\n    height: 8\n  },\n  includeStartNode: true,\n  includeEndNode: true\n});\n```\n\n### Allow path as close as possible\n\n```ts\nthis.aStarInstance = new AStarFinder({\n  grid: {\n    width: 8,\n    height: 8\n  },\n  allowPathAsCloseAsPossible: true\n});\n```\n\n## Prettier\n\nThis library uses [Prettier](https://github.com/prettier/prettier).\nThe configuration used can be seen in the `.prettierrc` file.\nMore informations about the format options can be found [here](https://prettier.io/docs/en/options.html).\n\n## License\n\n[MIT License](https://opensource.org/licenses/mit-license.php)\n\nCopyright (c) 2017 - 2023 digitsensitive \u003cdigit.sensitivee@gmail.com\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","funding_links":["https://www.buymeacoffee.com/JZDVjsT26"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitsensitive%2Fastar-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitsensitive%2Fastar-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitsensitive%2Fastar-typescript/lists"}