Giter VIP home page Giter VIP logo

knightstour's Introduction

Knights Tour

Info about the Knights Tour problem as described by wikipedia:

A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. If the knight ends on a square that is one knight's move from the beginning square (so that it could tour the board again immediately, following the same path), the tour is closed, otherwise it is open.

For more info: https://en.wikipedia.org/wiki/Knight%27s_tour

knight

Running

The main programs use python to run. or if you want to try the C implementation, a C compliler.

Running Python files.

To simply return a tour of a given size in the form of a list, you can run the knightsTour.py file with command line arguments to specify the size of the board and start position.

$ python knightsTour.py <boardsize> <start X> <start Y>

eg:

$ python knightsTour.py 24 8 6

If no arguments are specified the board will default to a 8x8 size and start at the co-oridnates (0,0)

To run the GUI Visualser pygame is required. The command arguments are slightly different here. This is as follows.

$ python guiVisualiser.py <algebraic position notation> <size>

eg:

$ python guiVisualiser.py a4 8

Here if no arguments are specified the board will default again to a 8x8 size and at position a1. Because of the design of the interface the board will not render a board bigger than 52x52. The layout design starts becoming squashed at around 32x32 but is still essentially works.

In the gui visualiser once the program has completed its first tour it will start again from its finishing position.

In both cases if you specify a position that is outside the range of the board you will get an assertion error.

Gui Controls.

To play the squence press the space key. To pause the squence press the space key again.

8x8 Example

knight gui

32x32 Example

knight gui

About this Implementation

For more info about the implementation, see analysis in the jupyter notebook. Its a bit of a mess right now and probally isnt up to date.

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.