{"id":17998396,"url":"https://github.com/primaryobjects/eightpuzzle","last_synced_at":"2025-04-04T06:42:13.421Z","repository":{"id":26004760,"uuid":"29447303","full_name":"primaryobjects/eightpuzzle","owner":"primaryobjects","description":"Eight Puzzle Solver using A*","archived":false,"fork":false,"pushed_at":"2015-01-21T02:34:33.000Z","size":156,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T17:47:47.276Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/primaryobjects.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}},"created_at":"2015-01-19T01:01:27.000Z","updated_at":"2024-02-20T02:58:23.000Z","dependencies_parsed_at":"2022-07-25T15:22:08.673Z","dependency_job_id":null,"html_url":"https://github.com/primaryobjects/eightpuzzle","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/primaryobjects%2Feightpuzzle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primaryobjects%2Feightpuzzle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primaryobjects%2Feightpuzzle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/primaryobjects%2Feightpuzzle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/primaryobjects","download_url":"https://codeload.github.com/primaryobjects/eightpuzzle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247135123,"owners_count":20889420,"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-10-29T21:25:10.307Z","updated_at":"2025-04-04T06:42:13.399Z","avatar_url":"https://github.com/primaryobjects.png","language":"JavaScript","readme":"Eight Puzzle Solver\n=========\n\nSolves the eight-puzzle (sliding block puzzle) by using the A* algorithm.\n\nA* Algorithm Details\n---\n\nThe program works by taking the starting state and evaluating the next possible moves, applying a cost value to each next state.\n\nThe cost (h) of a state is calculated by adding up the manhatten distance of each block from their goal state. For example, if a particular block is 3 moves left and 2 moves down from its goal state, then this adds 5 to the cost. You repeat this for the other blocks.\n\nA cost (g) is also applied to each state, which cooresponds to the depth to reach this part of the path. This provides a penalty to re-visiting an already-visited state.\n\nThe final A* cost of a state is: f(n) = h(n) + g(n)\n\nThe A* algorithm then selects the next unvisited state with the lowest cost. The selected state may even be a parent state, higher up in the path. Each child state records it's parent, so that once a solution is found, you can walk backwards up the parent path to return the solution.\n\nCompare the results of this program to online versions, using A* and manhatten distance:\nhttps://n-puzzle-solver.appspot.com/\nhttp://himanshug.info/8puzzle/8puzzle.html\n\nExamples\n---\n\n```\nstart: [4, 7, 6, \n        3, 2, 8, \n        0, 5, 1],\n\nend:   [1, 2, 3,\n        4, 5, 6,\n        7, 8, 0],\n```\nA solution is found in 22 steps.\nLLDRDRULURDLDRULLDRUUL\n\n```\nstart: [2, 1, 5, \n        4, 0, 7, \n        6, 8, 3],\n\nend:   [1, 2, 3,\n        4, 5, 6,\n        7, 8, 0],\n```\nA solution is found in 22 steps.\nLURDDLUURRDLULDRDRUULL\n\n```\nstart: [6, 4, 8, \n        1, 5, 7, \n        0, 3, 2],\n\nend:   [1, 2, 3,\n        4, 5, 6,\n        7, 8, 0],\n```\nA solution is found in 26 steps.\nLDDRUULDRULLDDRUULDDRURULL\n\nRunning It\n---\n\n```\nnode app\n```\n\nFun Fact\n----\n\nThe number of possible eight-puzzle configurations at each step from the goal can be calculated by running a breadth-first search from the goal. Then evaluate backwards down all paths. Doing this shows all possible board configurations from the goal, as shown below.\n\n![Screenshot 1](https://raw.githubusercontent.com/primaryobjects/eightpuzzle/master/depth/steps-from-goal.png)\n\nLicense\n----\n\nMIT\n\nAuthor\n----\nKory Becker\nhttp://www.primaryobjects.com/kory-becker","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimaryobjects%2Feightpuzzle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprimaryobjects%2Feightpuzzle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprimaryobjects%2Feightpuzzle/lists"}