GithubHelp home page GithubHelp logo

knights-tour's Introduction

Knight's Tour Problem Visual Solver

Two approaches for an open tour of a knight on a chess board

This project was something I built out of curiosity after I stumbled upon the Knight's Tour problem. The scripts provided, each in their own way find a valid path for an open tour for a knight chess piece. Provided are a bruteforce approach and a more heuristic solution using Warnsdorff's rule. Both approaches employ backtracking.

How to use

Instructions assume that the user has Git installed. If not installed, the documentation may help. All is done on the terminal.

  1. Create or navigate to a directory to clone the repository, and then clone it with this terminal command.
git clone https://github.com/C3viche/Knights-Tour.git
  1. Provided should be the up-to-date executable. Navigate to "Heuristic" or "Bruteforce" directory and run the executable.
cd Heuristic 
./knights_tour_op.exe

OR

cd Bruteforce
./knights_tour.exe
  1. The following input is required for each:

    Heuristic Solution (RECOMMENDED)

    • Dimensions of the abstract "chess board" (m x n)
    • The starting position of the knight in number coordinates
      • This is done because not all chess boards have letter indications
      • (0, 0) is the the top left corner, y increases going down the board, and x increases going right

    Brute Force

    Very unpolished. This was my beta version for the project so I highly recommend using the other program provided instead (Heuristic Solution using Warnsdorff's rule). However this program still does work for small chess boards like 5x5 and 6x6.

    • The starting position of the knight in number coordinates:
      • must be entered as x, y
      • not input validation, so very error prone

Keep in Mind...

Some boards and some starting positions may lead to impossible tours or long computing time for the computer so cancel the program with Ctrl + C if solution is not computed in under a minute. I am currently working on a script that automatically ends the program if not finished in time.

Visuals

5x5_Board 8x8_Board

Here are some resources I found interesting!

knights-tour's People

Contributors

c3viche avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.