{"id":19219218,"url":"https://github.com/ssarcandy/advance_n-puzzle_solver","last_synced_at":"2026-06-19T15:02:04.504Z","repository":{"id":23925137,"uuid":"27305841","full_name":"SSARCandy/Advance_n-puzzle_Solver","owner":"SSARCandy","description":"n-puzzle solver with obstacles, or with more than 1 space","archived":false,"fork":false,"pushed_at":"2016-07-08T12:26:11.000Z","size":269,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-04T19:28:10.426Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://ssarcandy.tw/Advance_n-puzzle_Solver/","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/SSARCandy.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":"2014-11-29T15:17:47.000Z","updated_at":"2016-07-08T12:26:23.000Z","dependencies_parsed_at":"2022-07-20T23:33:17.284Z","dependency_job_id":null,"html_url":"https://github.com/SSARCandy/Advance_n-puzzle_Solver","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/SSARCandy%2FAdvance_n-puzzle_Solver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SSARCandy%2FAdvance_n-puzzle_Solver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SSARCandy%2FAdvance_n-puzzle_Solver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SSARCandy%2FAdvance_n-puzzle_Solver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SSARCandy","download_url":"https://codeload.github.com/SSARCandy/Advance_n-puzzle_Solver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240292391,"owners_count":19778311,"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-11-09T14:29:58.113Z","updated_at":"2025-11-14T15:09:24.864Z","avatar_url":"https://github.com/SSARCandy.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"#Advance_n-puzzle_Solver \n\n\n### Introduction \n[N-puzzle](https://en.wikipedia.org/wiki/15_puzzle) (also called Gem Puzzle, Boss Puzzle, Game of Fifteen, Mystic Square and many others) is a sliding puzzle that consists of a frame of numbered square tiles in random order with one tile missing. The puzzle also exists in other sizes, particularly the smaller 8-puzzle. If the size is 3×3 tiles, the puzzle is called the 8-puzzle or 9-puzzle, and if 4×4 tiles, the puzzle is called the 15-puzzle or 16-puzzle named, respectively, for the number of tiles and the number of spaces. The object of the puzzle is to place the tiles in order (see diagram) by making sliding moves that use the empty space.\n\nIn this project, we can solved n-puzzle with **obstacles**(represent as `-1`), or with more than 1 **space**(represent as `0`)  \nThe algorithm is based on **A* algorithm**, alone with **Manhatten distance** as the score.\n\n\n\n### Run the code\n\n- Use terminal with [**CMake**](https://cmake.org/) (3.0+) \n\n\t```bash\n\t~$ cmake CMakeLists.txt\n\t~$ make \n\t~$ ./puzzle\n\t```\n- Use **XCode** or **Visual Studio**\n  - cmake-gui is easier to configure with these IDEs\n- Build yourself with g++\n\n\t```bash\n\t~$ g++ -o puzzle src/advance_8-puzzle.cpp include/puzzle.h\n\t~$ ./puzzle \u003c test/in12.txt \u003e out.txt\n\t```\n\n\n---\n\n### How To Use\n\n1. Using a sequence string to represent the puzzle state  \n\n###\n\t\tFor example:  \n\t\t12 1  3 4    will written as  \n\t\t11 2 13 5    ----------------\u003e   12,1,3,4;11,2,13,5;15,0,14,6;10,9,8,7;  \n\t\t15 0 14 6  \n\t\t10 9  8 7  \n\n2. In input data, first row is \"start state\", second is \"goal state\".  \n   The output format: First row is STEP1, second row is STEP2, until goal state。  \n   e.g. `(5,2,L)` is move position `(5,2) to LEFT`\n\n3. You can use standrad input(keyboard) or using redirect command  \n\tSomething like `./a.out \u003c in.txt \u003e out.txt`\n\n4. Sample Input and Output:  \n  \n###\n\t\tIn:\n\t\t12,1,3,4;11,2,13,5;15,0,14,6;10,9,8,7;  \n\t\t1,2,3,4;12,13,14,5;11,0,15,6;10,9,8,7; \n###\n\t\tOut:  \n\t\t(2, 3, L)  \n\t\t(1, 3, U)  \n\t\t(1, 2, U)  \n\t\t(1, 1, R)  \n\t\t(2, 1, D)  \n\t\t(2, 2, R)  \n\t\t(3, 2, D)  \n\t\t(3, 3, L)  \n                \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssarcandy%2Fadvance_n-puzzle_solver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fssarcandy%2Fadvance_n-puzzle_solver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssarcandy%2Fadvance_n-puzzle_solver/lists"}