welcome: please sign in
location: Diff for "KnightTour"
Differences between revisions 6 and 7
Revision 6 as of 2013-02-22 09:36:42
Size: 2856
Comment: update description and links
Revision 7 as of 2013-02-22 09:39:09
Size: 2964
Comment:
Deletions are marked like this. Additions are marked like this.
Line 51: Line 51:
 * 2013 02 22: update description - Now the chessboard might have holes, and no mandatory moves are given.

Knight Tour

Problem Description

Find a tour for the knight piece that starts at any square, travels all squares but the forbidden ones (representing holes on the board), and comes back to the origin, following the rules of chess and

Predicates

  • Input: size/1, forbidden/2

  • Output: move/4

Input format

The input file contains one atom size(N), which states that the chess board size is N*N and a number of atoms forbidden(X1,Y1). The rows of the board are numbered 1, 2, and so on up to N from top to bottom, and the columns are numbered 1, 2, and so on up to N from left to right. Each square can thus be represented by a unique pair of coordinates.

Output format

The output is a tour defined as a predicate

move(X1,Y1,X2,Y2). move(X2,Y2,X3,Y3). ... move(Xn,Yn,X1,Y1).

where each atom represents a valid move of the knight, all the squares are connected, and the last move brings the knight back to the origin. Moreover, no move ends onto a forbidden square.

Example(s)

A given input might be:

size(9).

forbidden(1,9). forbidden(2,9). forbidden(3,9). forbidden(4,9). forbidden(5,9). forbidden(6,9). forbidden(7,9). forbidden(8,9). forbidden(9,9).

forbidden(9,1). forbidden(9,2). forbidden(9,3). forbidden(9,4). forbidden(9,5). forbidden(9,6). forbidden(9,7). forbidden(9,8). forbidden(9,9).

Resulting in the following output:

move(1,1,2,3). move(1,2,3,3). move(1,3,3,4). move(1,4,3,5). move(1,5,3,4). move(1,6,3,5). move(1,7,3,8). move(1,8,2,6). move(2,1,3,3). move(2,2,1,4). move(2,3,3,5). move(2,4,4,3). move(2,5,3,3). move(2,6,3,8). move(2,7,3,5). move(2,8,4,7). move(3,1,4,3). move(3,2,5,1). move(3,3,5,2). move(3,4,2,6). move(3,5,1,4). move(3,6,4,8). move(3,7,5,8). move(3,8,5,7). move(4,1,3,3). move(4,2,3,4). move(4,3,6,2). move(4,4,2,3). move(4,5,6,4). move(4,6,5,8). move(4,7,2,6). move(4,8,6,7). move(5,1,7,2). move(5,2,6,4). move(5,3,3,4). move(5,4,4,6). move(5,5,4,3). move(5,6,3,5). move(5,7,4,5). move(5,8,4,6). move(6,1,7,3). move(6,2,4,3). move(6,3,7,5). move(6,4,8,5). move(6,5,4,6). move(6,6,4,5). move(6,7,4,8). move(6,8,4,7). move(7,1,5,2). move(7,2,5,1). move(7,3,8,5). move(7,4,6,2). move(7,5,6,7). move(7,6,6,4). move(7,7,8,5). move(7,8,5,7). move(8,1,6,2). move(8,2,7,4). move(8,3,6,4). move(8,4,7,2). move(8,5,7,3). move(8,6,7,4). move(8,7,7,5). move(8,8,6,7).

Additional sample instances: download

Problem Peculiarities

Type: Search Competition: System Track

Notes and Updates

  • 2013 02 22: update description - Now the chessboard might have holes, and no mandatory moves are given.

Author(s)

  • Author: Francesco Calimeri
    • Affiliation: University of Calabria, Italy
  • Original Author: Neng-Fa Zhou
    • Affiliation: CUNY Brooklyn College

ASP Competition 2013: KnightTour (last edited 2013-03-14 22:26:43 by FrancescoCalimeri)