{"id":17237899,"url":"https://github.com/sgalal/knights-tour-visualization","last_synced_at":"2025-06-30T02:03:38.700Z","repository":{"id":167522876,"uuid":"134795338","full_name":"sgalal/knights-tour-visualization","owner":"sgalal","description":"An online Knight's tour visualizer using divide and conquer algorithm","archived":false,"fork":false,"pushed_at":"2020-07-09T02:17:07.000Z","size":733,"stargazers_count":19,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-03T05:35:09.961Z","etag":null,"topics":["algorithm","divide-and-conquer","emscripten","html5","knight-tour","knights-tour","visualization","visualizer"],"latest_commit_sha":null,"homepage":"https://sgalal.github.io/knights-tour-visualization/","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/sgalal.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,"zenodo":null}},"created_at":"2018-05-25T02:54:01.000Z","updated_at":"2024-07-05T08:13:40.000Z","dependencies_parsed_at":"2023-05-22T19:00:39.296Z","dependency_job_id":null,"html_url":"https://github.com/sgalal/knights-tour-visualization","commit_stats":null,"previous_names":["sgalal/knights-tour-visualization"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sgalal/knights-tour-visualization","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgalal%2Fknights-tour-visualization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgalal%2Fknights-tour-visualization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgalal%2Fknights-tour-visualization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgalal%2Fknights-tour-visualization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sgalal","download_url":"https://codeload.github.com/sgalal/knights-tour-visualization/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgalal%2Fknights-tour-visualization/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262697251,"owners_count":23349890,"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":["algorithm","divide-and-conquer","emscripten","html5","knight-tour","knights-tour","visualization","visualizer"],"created_at":"2024-10-15T05:44:05.387Z","updated_at":"2025-06-30T02:03:38.679Z","avatar_url":"https://github.com/sgalal.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Knight's Tour Visualization\n\n[![Build status](https://ci.appveyor.com/api/projects/status/a3t55hc7dcxlwlg2?svg=true)](https://ci.appveyor.com/project/chromezh/knights-tour-visualization) [![Maintainability](https://api.codeclimate.com/v1/badges/31c1219b5c34c6108000/maintainability)](https://codeclimate.com/github/sgalal/knights-tour-visualization/maintainability)\n\n_An online [Knight's tour](https://en.wikipedia.org/wiki/Knight%27s_tour) visualizer using divide and conquer algorithm_\n\nThis project uses [Emscripten](http://kripken.github.io/emscripten-site/) to compile C code into JavaScript.\n\nFor an online version, see \u003chttps://sgalal.github.io/knights-tour-visualization/\u003e.\n\n![Knight's Tour on a 14\\*14 board](demo/demo.gif)\n\n## Project Structure\n\n* Source files: `src`\n* For test: `test`\n* For web pages: `index.html`, `index.js`, `index.css`\n\n## Build\n\n* **Prerequisite**: [Emscripten](http://kripken.github.io/emscripten-site/)\n* **Build**: `emcc -std=c11 -Weverything -Werror -Wno-unused-function -Wno-language-extension-token -O2 -s ASSERTIONS=1 -s EXPORTED_FUNCTIONS='[\"_getNextPointSerialize\"]' -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\",\"cwrap\"]' -o tour.js src/tour.c`\n* **Test**: `clang -std=c11 -Weverything -Werror -Wno-language-extension-token -DDEBUG -o tour src/tour.c test/tour_tb.c \u0026\u0026 ./tour`\n\n## Implementation\n\n### Algorithm\n\nThe code is an implementation of _Parberry, Ian. \"An efficient algorithm for the Knight's tour problem.\" Discrete Applied Mathematics 73.3(1997):251-260_.\n\nA knight’s tour is called _**closed**_ if the last square visited is also reachable from the first square by a knight’s move.\n\nA knight’s tour is said to be _**structured**_ if it includes the knight’s moves shown in Fig. 1.\n\n![Fig. 1. Required moves for a structured knight's tour.](demo/Fig1.jpg)\n\nAn _n_ \\* _n_ chessboard has a closed knight's tour iff _n_ ≥ 6 is even.\n\nFor board size of 6 \\* 6, 6 \\* 8, 8 \\* 8, 8 \\* 10, 10 \\* 10, and 10 \\* 12, we have already found **structured**, **closed** knight’s tours, which are shown in Fig. 2.\n\n![Fig. 2. Structured knight’s tours for (in row-major order) 6 x 6, 6 x 8, 8 x 8, 8 x 10, 10 x 10, and 10 x 12 boards.](demo/Fig2.jpg)\n\nThis means the problem is already solved when _n_ ∈ {6, 8, 10}.\n\nFor larger _n_, divide the chess board into parts to meet the sizes above. For instance, a board with _n_ = 42 can be divided as follows:\n\n![Divide example](demo/divide_example.svg)\n\nThen connect the parts together. Since all the parts are structured, we can combine them by substitute the directions on the corners:\n\n![Fig. 3. How to combine four structured knight’s tours into one.](demo/Fig3.jpg)\n\n### Data Structure\n\nSince every point is connected with other two points, and there are only 8 possible directions (from 0 to 7):\n\n![8 directions](demo/direction.svg)\n\nThe 6 pre-defined tours are stored in 2-dimensional arrays.\n\nThere are 8 types of corners (as were shown in Fig. 3.), which are denoted by 0-7, is recorded in _**point attribute**_. Besides, the point attribute of ordinary points is 8.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgalal%2Fknights-tour-visualization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgalal%2Fknights-tour-visualization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgalal%2Fknights-tour-visualization/lists"}