{"id":16027847,"url":"https://github.com/wisn/knights-tour","last_synced_at":"2025-04-05T04:43:11.145Z","repository":{"id":138974099,"uuid":"129909645","full_name":"wisn/knights-tour","owner":"wisn","description":"The Knight's Tour Algorithms in C++","archived":false,"fork":false,"pushed_at":"2018-05-04T15:20:00.000Z","size":87800,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-10T12:43:02.234Z","etag":null,"topics":["cpp11","knight-tour","telkom-university","warnsdorff"],"latest_commit_sha":null,"homepage":null,"language":"C++","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/wisn.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-04-17T13:34:41.000Z","updated_at":"2022-12-22T15:10:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"3af1b3f7-8cb3-40ca-baa2-7bba7c0c5cbf","html_url":"https://github.com/wisn/knights-tour","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"9921cf0ba5c56d3405e702a44a11d7ad1170a247"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wisn%2Fknights-tour","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wisn%2Fknights-tour/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wisn%2Fknights-tour/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wisn%2Fknights-tour/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wisn","download_url":"https://codeload.github.com/wisn/knights-tour/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247289394,"owners_count":20914464,"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":["cpp11","knight-tour","telkom-university","warnsdorff"],"created_at":"2024-10-08T20:23:53.966Z","updated_at":"2025-04-05T04:43:11.125Z","avatar_url":"https://github.com/wisn.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Knight's Tour\n\nThe Knight's tour algorithms in C++.\nSeveral algorithms implementation and its outputs included.\nThis repository created for educational purpose.\n\n## Implementation\n\n* [x] Brute-force algorithm\n* [x] Common backtracking algorithm\n* [x] Warnsdorff's rule algorithm\n\n## Outputs\n\nThere are several outputs available for each implementation.\nThe solution (output) is based on the Knight's legal `moves` sequence.\nEach type of sequence will produces different solution.\nThe default moves is\n`{(1, 2), (2, 1), (-1, 2), (1, -2), (-2, 1), (2, -1), (-2, -1), (-1, -2)}`\nin the form of `(x, y)`.\n\nAs an example, from that sequence above, using the starting point at `(0, 0)`\non the 8x8 chessboard, the output will be:\n\n```\n 1  16  59  34   3  18  21  36\n58  33   2  17  52  35   4  19\n15  64  49  60  45  20  37  22\n32  57  44  53  48  51  42   5\n63  14  61  50  43  46  23  38\n28  31  56  47  54  41   6   9\n13  62  29  26  11   8  39  24\n30  27  12  55  40  25  10   7\n```\n\nThen, if we change the sequence to\n`{2, 1}, {1, 2}, {-1, 2}, {-2, 1}, {-2, -1}, {-1, -2}, {1, -2}, {2, -1}`\nin the form of `(x, y)`, the output will be:\n\n```\n 1  34   3  18  49  32  13  16\n 4  19  56  33  14  17  50  31\n57   2  35  48  55  52  15  12\n20   5  60  53  36  47  30  51\n41  58  37  46  61  54  11  26\n 6  21  42  59  38  27  64  29\n43  40  23   8  45  62  25  10\n22   7  44  39  24   9  28  63\n```\n\n#### How to generate the outputs?\n\nFirst, edit the part of `n` variable which is denoting the chessboard.\nAs an example, edit it to this code below.\n\n```c++\nint n;\nscanf(\"%d\", \u0026n);\n```\n\nCompile the source code into an executable file.\nI assume that we using the \\*NIX family operating system and `g++` compiler.\n\n```bash\ng++ implementation-name.cpp -std=c++11 -o exe\n```\n\nThen, using the command line (bash), write this command below.\n\n```bash\nfor i in {1..100}\ndo\n  ./exe \u003c\u003c\u003c $i \u003e output-path/algorithm-name-$i.out\n  echo $1 \" done.\"\ndone\n```\n\nEdit the `{1..100}` interval part as we needed.\nLast, wait until its done.\n\n### Brute-force Implementation\n\nThere are at least 10 outputs included.\n\n### Common Backtracking Implementation\n\nThere are at least 10 outputs included.\n\n### Warnsdorff's Rule Implementation\n\nSince the file size is too huge, there are at least 50 outputs included.\n\n## Performance Comparison\n\nSince 2x2, 3x3, and 4x4 doesn't have any solution, we skip them.\n\n### Hardware Specifications\n\nTested on the ASUS A455L Notebook with the Intel Core i3-5005U 2GHz\nand 4GB DDR3 RAM.\n\n### Comparison Result\n\nFor each algorithm, the form of the result will be\n`A (B, C)`\nwhere\n`A` is the first try success at the random starting point (seconds),\n`B` is the number of success starting point(s),\nand `C` is the number of fails starting point(s).\nThe fails starting point could be either timeout or no solution found.\nThe timeout limit is 20 seconds for each starting point.\n\n| N (NxN) | Brute-force      | Common Backtracking | Warnsdorff's Rule  |\n|---------|------------------|---------------------|--------------------|\n| 1       | 0.00s (1, 0)     | 0.00s (1, 0)        | 0.00s (1, 0)       |\n| 5       | 0.10s (13, 12)   | 0.16s (13, 12)      | 0.00s (10, 15)     |\n| 6       | 0.25s (24, 12)   | 0.19s (24, 12)      | 0.00s (36, 0)      |\n| 7       | 0.72s (16, 33)   | 0.16s (16, 33)      | 0.00s (20, 29)     |\n| 8       | 10.21s (5, 59)   | 6.61s (6, 58)       | 0.00s (63, 1)      |\n| 9       | Timeout (0, 81)  | Timeout (0, 81)     | 0.00s (41, 40)     |\n| 10      | Timeout (0, 100) | Timeout (0, 100)    | 0.00s (100, 0)     |\n| 11      | TBA              | TBA                 | 0.00s (59, 62)     |\n| 12      | TBA              | TBA                 | 0.00s (141, 3)     |\n| 13      | TBA              | TBA                 | 0.00s (84, 85)     |\n| 14      | TBA              | TBA                 | 0.00s (192, 4)     |\n| 15      | TBA              | TBA                 | 0.00s (113, 112)   |\n| 16      | TBA              | TBA                 | 0.00s (254, 2)     |\n| 17      | TBA              | TBA                 | 0.00s (144, 145)   |\n| 18      | TBA              | TBA                 | 0.00s (317, 7)     |\n| 19      | TBA              | TBA                 | 0.00s (178, 183)   |\n| 20      | TBA              | TBA                 | 0.00s (395, 5)     |\n| 21      | TBA              | TBA                 | 0.00s (216, 225)   |\n| 22      | TBA              | TBA                 | 0.00s (478, 6)     |\n| 23      | TBA              | TBA                 | 0.00s (263, 266)   |\n| 24      | TBA              | TBA                 | 0.00s (566, 10)    |\n| 25      | TBA              | TBA                 | 0.00s (310, 315)   |\n| 26      | TBA              | TBA                 | 0.00s (658, 18)    |\n| 27      | TBA              | TBA                 | 0.01s (356, 373)   |\n| 28      | TBA              | TBA                 | 0.01s (774, 10)    |\n| 29      | TBA              | TBA                 | 0.01s (417, 424)   |\n| 30      | TBA              | TBA                 | 0.01s (849, 51)    |\n| 31      | TBA              | TBA                 | 0.01s (480, 481)   |\n| 32      | TBA              | TBA                 | 0.01s (975, 49)    |\n| 33      | TBA              | TBA                 | 0.01s (537, 552)   |\n| 34      | TBA              | TBA                 | 0.01s (1045, 111)  |\n| 35      | TBA              | TBA                 | 0.01s (607, 618)   |\n| 36      | TBA              | TBA                 | 0.01s (1248, 48)   |\n| 37      | TBA              | TBA                 | 0.01s (673, 696)   |\n| 38      | TBA              | TBA                 | 0.01s (1268, 176)  |\n| 39      | TBA              | TBA                 | 0.01s (746, 775)   |\n| 40      | TBA              | TBA                 | 0.01s (1530, 70)   |\n| 41      | TBA              | TBA                 | 0.01s (829, 852)   |\n| 42      | TBA              | TBA                 | 0.01s (1543, 221)  |\n| 43      | TBA              | TBA                 | 0.01s (914, 935)   |\n| 44      | TBA              | TBA                 | 0.01s (1852, 84)   |\n| 45      | TBA              | TBA                 | 0.01s (968, 1057)  |\n| 46      | TBA              | TBA                 | 0.02s (1778, 338)  |\n| 47      | TBA              | TBA                 | 0.02s (1082, 1127) |\n| 48      | TBA              | TBA                 | 0.02s (2204, 100)  |\n| 49      | TBA              | TBA                 | 0.02s (1148, 1253) |\n| 50      | TBA              | TBA                 | 0.02s (2116, 384)  |\n| 51      | TBA              | TBA                 | 0.02s (1274, 1327) |\n| 52      | TBA              | TBA                 | 0.02s (2587, 117)  |\n| 53      | TBA              | TBA                 | 0.02s (1352, 1457) |\n| 54      | TBA              | TBA                 | 0.02s (2405, 511)  |\n| 55      | TBA              | TBA                 | 0.02s (1476, 1549) |\n| 56      | TBA              | TBA                 | 0.02s (2972, 164)  |\n| 57      | TBA              | TBA                 | 0.02s (1548, 1701) |\n| 58      | TBA              | TBA                 | 0.03s (2791, 573)  |\n| 59      | TBA              | TBA                 | 0.03s (1697, 1784) |\n| 60      | TBA              | TBA                 | 0.03s (3448, 152)  |\n| 61      | TBA              | TBA                 | 0.03s (1770, 1951) |\n| 62      | TBA              | TBA                 | 0.03s (3143, 701)  |\n| 63      | TBA              | TBA                 | 0.03s (1918, 2051) |\n| 64      | TBA              | TBA                 | 0.03s (3874, 222)  |\n| 65      | TBA              | TBA                 | 0.03s (2011, 2214) |\n| 66      | TBA              | TBA                 | 0.03s (3480, 876)  |\n| 67      | TBA              | TBA                 | 0.03s (2181, 2308) |\n| 68      | TBA              | TBA                 | 0.04s (4414, 210)  |\n| 69      | TBA              | TBA                 | 0.04s (2225, 2536) |\n| 70      | TBA              | TBA                 | 0.04s (3877, 1023) |\n| 71      | TBA              | TBA                 | 0.04s (2440, 2601) |\n| 72      | TBA              | TBA                 | 0.04s (4921, 263)  |\n| 73      | TBA              | TBA                 | 0.04s (2474, 2855) |\n| 74      | TBA              | TBA                 | 0.04s (4265, 1211) |\n| 75      | TBA              | TBA                 | 0.04s (2699, 2926) |\n| 76      | TBA              | TBA                 | 0.04s (5506, 270)  |\n| 77      | TBA              | TBA                 | 0.05s (2768, 3161) |\n| 78      | TBA              | TBA                 | 0.05s (4828, 1256) |\n| 79      | TBA              | TBA                 | 0.05s (3006, 3235) |\n| 80      | TBA              | TBA                 | 0.05s (6091, 309)  |\n| 81      | TBA              | TBA                 | 0.05s (3027, 3524) |\n| 82      | TBA              | TBA                 | 0.05s (5192, 1532) |\n| 83      | TBA              | TBA                 | 0.05s (3333, 3556) |\n| 84      | TBA              | TBA                 | 0.05s (6655, 401)  |\n| 85      | TBA              | TBA                 | 0.05s (3307, 3918) |\n| 86      | TBA              | TBA                 | 0.05s (5717, 1679) |\n| 87      | TBA              | TBA                 | 0.06s (3581, 3988) |\n| 88      | TBA              | TBA                 | 0.06s (7352, 392)  |\n| 89      | TBA              | TBA                 | 0.06s (3600, 4321) |\n| 90      | TBA              | TBA                 | 0.06s (6163, 1937) |\n| 91      | TBA              | TBA                 | 0.06s (4006, 4275) |\n| 92      | TBA              | TBA                 | 0.06s (7972, 492)  |\n| 93      | TBA              | TBA                 | 0.06s (3925, 4724) |\n| 94      | TBA              | TBA                 | 0.07s (6730, 2106) |\n| 95      | TBA              | TBA                 | 0.07s (4309, 4716) |\n| 96      | TBA              | TBA                 | 0.07s (8721, 495)  |\n| 97      | TBA              | TBA                 | 0.07s (4267, 5142) |\n| 98      | TBA              | TBA                 | 0.07s (7337, 2272) |\n| 99      | TBA              | TBA                 | 0.07s (4727, 5074) |\n| 100     | TBA              | TBA                 | 0.07s (9503, 492)  |\n\n### Conclusion\n\nThe Warnsdorff's Rule just took about 0.07s for finding a random solution\n(in the first try) on the 100x100 chessboard.\n\n### Margin of Error\n\nPlease take a note that the Brute-force and the common backtracking\nanalysis result contains margin of error. The first try result from\nrandom starting point is only taken by one arbitrary sample which is\nnot the optimal one. Hence, there may be unfair result occurred.\n\n## License\n\n### Source Code License\n\nLicensed under [The MIT License](LICENSE).\nYou could use the source code for whatever you want as long as the\n`LICENSE` file or the license header in the source code still there.\n\n### Documentation License\n\nAll reading materials from this repository is licensed under\n[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).\nYou could use this repository as your reference as long as you\ngive the attribution.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwisn%2Fknights-tour","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwisn%2Fknights-tour","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwisn%2Fknights-tour/lists"}