{"id":33050964,"url":"https://github.com/felselva/uastar","last_synced_at":"2026-01-17T01:22:50.306Z","repository":{"id":52154349,"uuid":"113478242","full_name":"felselva/uastar","owner":"felselva","description":"Minimal A* implementation in C. No dynamic memory allocation.","archived":false,"fork":false,"pushed_at":"2024-04-17T22:28:48.000Z","size":24,"stargazers_count":130,"open_issues_count":2,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2026-01-07T08:26:35.071Z","etag":null,"topics":["a-star","pathfinder","pathfinding","pure-c"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/felselva.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-12-07T17:10:52.000Z","updated_at":"2025-08-27T18:10:24.000Z","dependencies_parsed_at":"2024-07-10T11:42:12.838Z","dependency_job_id":"adf82c55-cec5-4e0d-bb64-17ac3092b732","html_url":"https://github.com/felselva/uastar","commit_stats":null,"previous_names":["ferreiradaselva/uastar"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/felselva/uastar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felselva%2Fuastar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felselva%2Fuastar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felselva%2Fuastar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felselva%2Fuastar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felselva","download_url":"https://codeload.github.com/felselva/uastar/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felselva%2Fuastar/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28491392,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T00:50:05.742Z","status":"ssl_error","status_checked_at":"2026-01-17T00:43:11.982Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["a-star","pathfinder","pathfinding","pure-c"],"created_at":"2025-11-14T03:00:23.119Z","updated_at":"2026-01-17T01:22:50.296Z","avatar_url":"https://github.com/felselva.png","language":"C","funding_links":[],"categories":["游戏编程","C"],"sub_categories":[],"readme":"# Micro A Star Path Finder\n\nThis is a minimal A* path finder implementation in C, without any dynamic memory allocation.\n\n## Usage\n\nThe maximum size of the map is defined by the macro `PATH_FINDER_MAX_CELLS`, which can be modified to support larger maps.\n\nThe size of the map is defined by the variables `cols` and `rows` in the `path_finder` structure, and the total of cells must be smaller or equal to `PATH_FINDER_MAX_CELLS`.\n\n```c\nstruct path_finder path_finder = {0};\npath_finder.cols = 24;\npath_finder.rows = 24;\ninit_path_finder(\u0026path_finder);\npath_finder.data = game;\n/* Callback to fill the initial state of the cells */\npath_finder.fill_func = fill_cb;\n/* Callback to set the custom score to the cells while finding a path */\npath_finder.score_func = score_cb;\n/* Fill with the initial state of the cells and the custom score */\npath_finder_fill(\u0026path_finder, game_object);\npath_finder_set_start(\u0026path_finder, from_col, from_row);\npath_finder_set_end(\u0026path_finder, to_col, to_row);\n/* Find the path */\npath_finder_find(\u0026path_finder, game_object);\n```\n\nThe callback `fill_func` is necessary to define which cells are passable and which are non-passable:\n\n```c\n/* The parameters `col` and `row` indicate the cell of the map we are setting as passable or non-passable */\nstatic bool fill_cb(struct path_finder *path_finder, int32_t col, int32_t row)\n{\n\tstruct game *game;\n\tuint8_t is_passable;\n\tgame = path_finder-\u003edata;\n\tis_passable = 0;\n\tif (is_wall(game, col, row) == 1) {\n\t\tis_passable = 0;\n\t}\n\treturn is_passable;\n}\n```\n\nThe callback `score_func` is optional and is called during the `path_finder_find` execution. The callback also takes a custom pointer, useful to point to a specific object. Use it to add custom score to the cells:\n\n```c\n/* The parameters `col` and `row` indicate the cell of the map we are setting a score */\nstatic int32_t score_cb(struct path_finder *path_finder, int32_t col, int32_t row, void *data)\n{\n\tstruct game *game;\n\tstruct game_object *game_object;\n\tint32_t value;\n\tgame = path_finder-\u003edata;\n\tgame_object = data;\n\tvalue = 0;\n\tif (is_danger_zone(game, col, row) == 1) {\n\t\t/* The higher the value, the more avoided the cell is */\n\t\tvalue = 5;\n\t\tif (is_fearless(game_object) == 1) {\n\t\t\t/* Unless the character is fearless */\n\t\t\tvalue = 0;\n\t\t}\n\t}\n\t/* The value returned is incremented in the cell score */\n\treturn value;\n}\n```\n\nTo check if a cell is a path, access the path finder array directly or use `path_finder_is_path` (be careful, this function doesn't check the passed values of column and row are inside the range of the map dimensions, as they should be):\n\n```c\ncell_is_path = path_finder_is_path(\u0026path_finder, col, row);\n```\n\nIf a path is found by the path finder, the value of `has_path` inside the structure `path_finder` is set to `1`.\n\nIt is also possible to process only one step of the path finder at a time, useful to divide the processing in multiple frames:\n\n```c\nuint8_t still_working;\npath_finder_begin(\u0026path_finder);\nstill_working = path_finder_find_step(\u0026path_finder, NULL);\n```\n\nOr, to run the entire process, but drawing the intermediate steps:\n\n```c\npath_finder_begin(\u0026path_finder);\nwhile (path_finder_find_step(\u0026path_finder, NULL) == 1) {\n\tdraw();\n}\n```\n\n## Test\n\nThe test generates an output with the map:\n\n```\n./test 0 80 12345 0 0 23 11 24 13\n  Passable chance: 80\n            Start: 'S' (or 's' if fall in a wall)\n              End: 'E' (or 'e' if fall in a wall)\n        Open path: 'O'\n      Closed path: 'X'\n             Path: '*'\n       Unpassable: '#'\nMap:\n##########################\n#S#    #      #       #  #\n#****###  #      # ##    #\n### **#******##    #     #\n###  ***#  #**  #   # ## #\n#  #  ## #   * # #  #  # #\n#   ##  #    *# ##       #\n## #   # #  #****#       #\n#    #     #    *******  #\n#   #  #      #  #    *# #\n# #  #  ##         # #**##\n# # #       ##         **#\n#                       E#\n#  #    ## # ### #    #  #\n##########################\nA path was found!\n```\n\n## LICENSE\n\nThe source code of this project is licensed under the terms of the ZLIB license:\n\nCopyright (c) 2017 Felipe Ferreira da Silva\n\nThis software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:\n\n1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\n2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\n3. This notice may not be removed or altered from any source distribution.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelselva%2Fuastar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelselva%2Fuastar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelselva%2Fuastar/lists"}