Simulate the Knight's Tour

Introduction

This assignment will give you practice with Python, data structures, and design.


The Assignment

You will write a Python program that attempts to solve the Knight's Tour for a given board by luck. The Knight's Tour is an attempt to move the knight on a board, such that each space is visited exactly once. See the Web for more information.

Your program will read 3 arguments: rows, columns, attempts . The first 2 arguments are the size of the board, rows x columns. The last argument is the number of attempts to make.

The knight will start at (1, 1). Look around, see what moves are available, and randomly choose one (note, that is not the same as randomly choosing a move, and then seeing if it's legal). If you have no more moves (and you haven't covered the board), then the knight didn't make it.

You then continue with a fresh attempt, starting at (1, 1), until the knight succeeds, or you've used up the number of attempts. At the end, whichever the outcome, you will print a history of the knight's last attempt, w/a "success" or "failure" message. E.g., given a 3x3 board, output:

FAIL:
 1  6  3 
 4  x  8 
 7  2  5

Your code

You'll need some smart way to store the moves you made on the board.


Output

The history of the last attempt, as described above.


Submission

Submit the following files, via Blackboard:

Please note You will use the filenames as listed here, and submit them all to the proper assignment. If this is not clear, then see me in class. If I get programs submitted to the wrong directories, I will be irate, which may, in some subconscious way, affect your grades. Adversely.