{"id":31580110,"url":"https://github.com/solarlune/paths","last_synced_at":"2025-10-05T21:07:02.268Z","repository":{"id":33509671,"uuid":"158954550","full_name":"SolarLune/paths","owner":"SolarLune","description":"paths is a pathfinding library written in Golang for use with games.","archived":false,"fork":false,"pushed_at":"2023-11-14T19:20:52.000Z","size":33,"stargazers_count":63,"open_issues_count":4,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-10-01T05:25:11.378Z","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/SolarLune.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2018-11-24T16:34:35.000Z","updated_at":"2024-12-11T14:25:57.000Z","dependencies_parsed_at":"2024-06-18T22:54:38.056Z","dependency_job_id":null,"html_url":"https://github.com/SolarLune/paths","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SolarLune/paths","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Fpaths","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Fpaths/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Fpaths/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Fpaths/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SolarLune","download_url":"https://codeload.github.com/SolarLune/paths/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SolarLune%2Fpaths/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278518950,"owners_count":26000184,"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","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-10-05T21:06:58.443Z","updated_at":"2025-10-05T21:07:02.252Z","avatar_url":"https://github.com/SolarLune.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# paths\n\n![paths](https://user-images.githubusercontent.com/4733521/48970683-21882880-efc4-11e8-9b60-670f46c6fd77.gif)\n\n[GoDocs](https://pkg.go.dev/github.com/SolarLune/paths?tab=doc)\n\n## What is paths?\n\npaths is a pathfinding library written in Golang created mainly for video games. Its main feature is simple best-first and shortest-cost path finding.\n\n## Why is it called that?\n\nBecause I finally learned how to spell.\n\n## Why did you create paths?\n\nBecause I needed to do pathfinding for a game and couldn't really find any pre-made Golang libraries that seemed to do this, so... Yet again, here we are.\n\n## How do I install it?\n\nJust go get it:\n\n`go get github.com/solarlune/paths`\n\n## How do I use it?\n\npaths is based around defining a Grid, which consists of a rectangular series of Cells. Each Cell occupies a single X and Y position in space, and has a couple of properties that influence pathfinding, which are Cost and Walkability. If a Cell isn't walkable, then it is considered an obstacle that paths generated must circumvent. All Cells default to a Cost of 1; pathfinding will prioritize lower-cost Cells.\n\n```go\nimport \"github.com/SolarLune/paths\"\n\nfunc Init() {\n\n    // This line creates a new Grid, comprised (internally) of Cells. The size is 10x10. Each Cell's \n    // \"world\" size is 16x16. By default, all Cells are walkable, have a cost of 1, and a blank rune \n    // of ' ' associated with them.\n    firstMap = paths.NewGrid(10, 10, 16, 16)\n    \n    // You can also create the Grid from an array of strings (which are interpreted as arrays of runes), \n    // if you already have it:\n    layout := []string{\n        \"xxxxxxxxxx\",\n        \"x        x\",\n        \"x xxxxxx x\",\n        \"x xg   x x\",\n        \"x xgxx x x\",\n        \"x gggx x x\",\n        \"x xxxx   x\",\n        \"x  xgg x x\",\n        \"xg ggx x x\",\n        \"xxxxxxxxxx\",\n    }\n\n    secondMap := paths.NewGridFromStringArrays(layout, 16, 16)\n\n    // After creating the Grid, you can edit it using the Grid's functions. Note that here, we're using 'x' \n    // to get Cells that have the rune for the lowercase x character 'x', not the string \"x\".\n    firstMap.SetWalkable('x', false)\n\n    // You can also loop through them by using the `GetCells` functions thusly...\n    for _, goop := range secondMap.GetCellsByRune('g') {\n        goop.Cost = 5\n    }\n\n    // This gets a new Path from the Cell occupied by a starting position [24, 21], to another [99, 78]. The last boolean argument,\n    // false, indicates whether moving diagonally is fine when creating the Path.\n    firstPath := GameMap.GetPath(24, 21, 99, 78, false)\n\n    // You can also get a path using references to the Cells directly.\n    secondPath := GameMap.GetPathFromCell(GameMap.Get(1, 1), GameMap.Get(6, 3), false)\n\n    // After that, you can use Path.Current() and Path.Next() to get the current and next Cells on the Path. When you determine that \n    // the pathfinding agent has reached that Cell, you can kick the Path forward with path.Advance().\n\n    // And that's it!\n\n}\n\n```\n---\n\nAnd that's about it! If you want to see more info or examples, feel free to examine the main.go and world.go tests to see how the test is set up.\n\n[You can check out the GoDoc link here, as well.](https://pkg.go.dev/github.com/SolarLune/paths?tab=doc)\n\nYou can also run the example by installing SDL with the instructions [here](https://github.com/veandco/go-sdl2#requirements)\nand then:\n\n```\n$ cd ./example\n$ go run ./\n```\n\n## Dependencies?\n\nFor the actual package, there are no external dependencies.\n\nFor the tests, paths requires veandco's sdl2 port to create the window, handle input, and draw the shapes and text.\n\n## Shout-out Time!\n\nProps to whoever made arcadepi.ttf! It's a nice font.\n\nThanks a lot to the SDL2 team for development.\n\nThanks to veandco for maintaining the Golang SDL2 port, as well!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolarlune%2Fpaths","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolarlune%2Fpaths","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolarlune%2Fpaths/lists"}