knight’s tour algorithm

Post on 05-Jun-2015

8.217 Views

Category:

Education

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

KNIGHT’S TOURExplanation and

Algorithms

GROUP MEMBERS

Hassan Tariq (2008-EE-180)

Zair Hussain Wani (2008-EE-178)

Introduction

What is ‘Knight’s Tour’?

Chess problem involving a knight

Start on a random square

Visit each square exactly ONCE according to rules

Tour called closed, if ending square is same as the starting

Constraints

A closed knight’s tour is always possible on an

m x n chessboard, unless:

m and n are both odd, but not 1

m is either 1, 2 or 4

m = 3, and n is either 4, 6 or 8

m and n are both odd, but not 1

Knight moves either from black square to white, or vice versa

In closed tour knight visits even squares

If m and n are odd i.e. 3x3, total squares are odd so tour doesn`t exist

m = 1, 2, or 4; m and n are not both 1

for m = 1 or 2, knight will not be able to reach every square

for m = 4, the alternate pattern of white and black square is not followed so tour not closed

m = 3; n = 4, 6, or 8

Have to be verified for each case

For n > 8, existence of closed tours can be proved by induction

Algorithms

Neural Network Solutions

Warnsdorff’s Algorithm

Neural Network Solutions

Every move represented by neuron

Each neuron initialized to be active or inactive

( 1 or 0 )

Each neuron having state function initialized to 0

Neural Network Solutions (contd.)

Ut+1 (Ni,j) = Ut(Ni,j) +2 – Vt(N)

NG(Ni,j)

1 Ut+1(Ni,j) > 3 Vt+1(Ni,j) = 0 Ut+1(Ni,j) < 0

Vt(Ni,j) otherwise

Neural Network Solutions (contd.)

The network ALWAYS converge

Solution: Closed knight’s tour Series of two or more open tours

Warnsdorff's Algorithm

Heuristic Method Each move made

to the square from which no. of subsequent moves is least

Warnsdorff's Algorithm (contd.)

Set P to be a random initial position on the board

Mark the board at P with the move number "1" For each move number from 2 to the number of

squares on the board: Let S be the set of positions accessible from the input

position Set P to be the position in S with minimum

accessibility Mark the board at P with the current move number

Return the marked board – each square will be marked with the move number on which it is visited.

Comparison

NEURAL NETWORKS WARNSDORFF'S ALGORITHM

Complex algorithm (a lot of variables to be monitored)

Longer run-time NOT always gives a

complete tour

Simple algorithm Linear run-time Always gives a

CLOSED tour

Conclusion

WARNSDORFF’S ALGORITHM IS BETTER

top related