An open API service indexing awesome lists of open source software.

https://github.com/lostjared/knights_tour.javascript

Solving Knights Tour in HTML5/JavaScript
https://github.com/lostjared/knights_tour.javascript

javascript knights-tour math puzzle

Last synced: 8 months ago
JSON representation

Solving Knights Tour in HTML5/JavaScript

Awesome Lists containing this project

README

          

# Knight's Tour Demo

![screenshot](https://github.com/lostjared/Knights_Tour.JavaScript/blob/main/screens/knights.tour.jpg)

This is a simple implementation of the Knight's Tour problem using HTML5 Canvas and JavaScript. The demo visualizes the knight's movement on an 8x8 chessboard, where the knight visits each square exactly once.

## Features

- Visual representation of the Knight's Tour on a chessboard.
- User can press the spacebar to move the knight to the next position.
- User can press the Enter key to reset the tour.

## Getting Started

To run this demo, simply open the the directory containing the project
run
```bash
python3 -m http.server 3000
```
open your web browser to localhost:3000

### Prerequisites

- A modern web browser (e.g., Chrome, Firefox, Edge).

## Files

- `index.html`: The main HTML file that sets up the canvas and includes the JavaScript file.
- `script.js`: The JavaScript file containing the logic for the Knight's Tour and drawing functions.
- `knight.png`: The image of the knight used in the demo.

## Usage

1. Download or clone the repository to your local machine.
2. Open in your web browser over http
3. Use the following keys to interact with the demo:
- `Space`: Move the knight to the next position.
- `Enter`: Reset the Knight's Tour.

## Implementation Details

The demo uses HTML5 Canvas to draw the chessboard and the knight. The knight image is processed to remove its white background and is drawn on the board at each step.

This project is open-source and available under the MIT License.