{"id":13366442,"url":"https://github.com/beefsack/Go-astar","last_synced_at":"2025-03-12T18:30:54.695Z","repository":{"id":17467773,"uuid":"20241916","full_name":"beefsack/go-astar","owner":"beefsack","description":"Go implementation of the A* search algorithm","archived":false,"fork":false,"pushed_at":"2022-01-27T15:08:37.000Z","size":19,"stargazers_count":591,"open_issues_count":3,"forks_count":79,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-07-31T01:25:04.505Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/beefsack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"beefsack"}},"created_at":"2014-05-28T02:00:03.000Z","updated_at":"2024-07-20T18:22:50.000Z","dependencies_parsed_at":"2022-07-16T03:00:33.655Z","dependency_job_id":null,"html_url":"https://github.com/beefsack/go-astar","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/beefsack%2Fgo-astar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beefsack%2Fgo-astar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beefsack%2Fgo-astar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beefsack%2Fgo-astar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beefsack","download_url":"https://codeload.github.com/beefsack/go-astar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221309819,"owners_count":16795816,"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":[],"created_at":"2024-07-30T00:01:24.882Z","updated_at":"2024-10-24T11:30:15.868Z","avatar_url":"https://github.com/beefsack.png","language":"Go","funding_links":["https://github.com/sponsors/beefsack"],"categories":["游戏开发","遊戲開發"],"sub_categories":["高级控制台界面","高級控制台界面"],"readme":"go-astar\n========\n\n**A\\* pathfinding implementation for Go**\n\n[![Build Status](https://travis-ci.org/beefsack/go-astar.svg?branch=master)](https://travis-ci.org/beefsack/go-astar)\n\nThe [A\\* pathfinding algorithm](http://en.wikipedia.org/wiki/A*_search_algorithm) is a pathfinding algorithm noted for its performance and accuracy and is commonly used in game development.  It can be used to find short paths for any weighted graph.\n\nA fantastic overview of A\\* can be found at [Amit Patel's Stanford website](http://theory.stanford.edu/~amitp/GameProgramming/AStarComparison.html).\n\nExamples\n--------\n\nThe following crude examples were taken directly from the automated tests.  Please see `path_test.go` for more examples.\n\n### Key\n\n*   `.` - Plain (movement cost 1)\n*   `~` - River (movement cost 2)\n*   `M` - Mountain (movement cost 3)\n*   `X` - Blocker, unable to move through\n*   `F` - From / start position\n*   `T` - To / goal position\n*   `●` - Calculated path\n\n### Straight line\n\n```\n.....~......      .....~......\n.....MM.....      .....MM.....\n.F........T.  -\u003e  .●●●●●●●●●●.\n....MMM.....      ....MMM.....\n............      ............\n```\n\n### Around a mountain\n\n```\n.....~......      .....~......\n.....MM.....      .....MM.....\n.F..MMMM..T.  -\u003e  .●●●MMMM●●●.\n....MMM.....      ...●MMM●●...\n............      ...●●●●●....\n```\n\n### Blocked path\n\n```\n............      \n.........XXX\n.F.......XTX  -\u003e  No path\n.........XXX\n............\n```\n\n### Maze\n\n```\nFX.X........      ●X.X●●●●●●..\n.X...XXXX.X.      ●X●●●XXXX●X.\n.X.X.X....X.  -\u003e  ●X●X.X●●●●X.\n...X.X.XXXXX      ●●●X.X●XXXXX\n.XX..X.....T      .XX..X●●●●●●\n```\n\n### Mountain climber\n\n```\n..F..M......      ..●●●●●●●●●.\n.....MM.....      .....MM...●.\n....MMMM..T.  -\u003e  ....MMMM..●.\n....MMM.....      ....MMM.....\n............      ............\n```\n\n### River swimmer\n\n```\n.....~......      .....~......\n.....~......      ....●●●.....\n.F...X...T..  -\u003e  .●●●●X●●●●..\n.....M......      .....M......\n.....M......      .....M......\n```\n\nUsage\n-----\n\n### Import the package\n\n```go\nimport \"github.com/beefsack/go-astar\"\n```\n\n### Implement Pather interface\n\nAn example implementation is done for the tests in `path_test.go` for the Tile type.\n\nThe `PathNeighbors` method should return a slice of the direct neighbors.\n\nThe `PathNeighborCost` method should calculate an exact movement cost for direct neighbors.\n\nThe `PathEstimatedCost` is a heuristic method for estimating the distance between arbitrary tiles.  The examples in the test files use [Manhattan distance](http://en.wikipedia.org/wiki/Taxicab_geometry) to estimate orthogonal distance between tiles.\n\n```go\ntype Tile struct{}\n\nfunc (t *Tile) PathNeighbors() []astar.Pather {\n\treturn []astar.Pather{\n\t\tt.Up(),\n\t\tt.Right(),\n\t\tt.Down(),\n\t\tt.Left(),\n\t}\n}\n\nfunc (t *Tile) PathNeighborCost(to astar.Pather) float64 {\n\treturn to.MovementCost\n}\n\nfunc (t *Tile) PathEstimatedCost(to astar.Pather) float64 {\n\treturn t.ManhattanDistance(to)\n}\n```\n\n### Call Path function\n\n```go\n// t1 and t2 are *Tile objects from inside the world.\npath, distance, found := astar.Path(t1, t2)\nif !found {\n\tlog.Println(\"Could not find path\")\n}\n// path is a slice of Pather objects which you can cast back to *Tile.\n```\n\nAuthors\n-------\n\nMichael Alexander \u003cbeefsack@gmail.com\u003e\nRobin Ranjit Chauhan \u003crobin@pathwayi.com\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeefsack%2FGo-astar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeefsack%2FGo-astar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeefsack%2FGo-astar/lists"}