An implementation of knight’s tour algorithm written in javascript & html5

A knight’s tour is a sequence of moves of a knight on a chessboards such that the knight visits every square exactly once. The knight’s tour problem is an instance of the more general Hamiltonian path problem in graph theory. we use the Warnsdorff’s rule “an heuristic algorithm”. We move the knight so that we always proceed to the square from which the knight will have the fewest onward moves. When calculating the number of onward moves for each candidate square, we do not count moves that revisit any square already visited. It is, of course, possible to have two or more choices for which the number of onward moves is equal. Below we can see the piece of code where the chessboard created using html5 and algorithm’s implementation in javascript. The algorithm chooses the square where the knight has the minimum value of possible moves. This is not the best approach because there are cases that the puzzle doesn’t have a solution as we can see at this paper. In a next post i’ll try to solve the problem. The knight’s tour has been tested in mozzila firefox and google chrome.


Cad implementation using the Javascript based topology library

Today I had some time and I decided to resurrect and update one sample page on how to use the topology Javascript library (codenamed tougo) I developed a couple of years ago.

The sample demonstrates some basic functions of a simple drawing app. You have the option to draw circles, boxes, triangles and lines. Originally I called it a Cad app cause you had the option edit the drawing and to export it to a dxf file.

The export option in this sample is deactivated (although the sample does includes the Javascript code to do so).

I may add a couple more features in due time.

enjoy the sample page and feel free to pop a question. Btw it only works on webkit browsers due to mozilla html5 canvas incompatibilities

UPDATE:  I updated my code to the latest version where I have solved the mozilla html5 canvas incompatibilities, so now it works,  just fine, on both browsers.