|
-
Mako Shark
knight's tour problem
I have a homework to write a program to solve the knights tour problem (user enters the starting square). I have to use the Warnsdorff's rule. the program prints out the moves from the starting square.
the HW assignment can be found here: http://www.sci.brooklyn.cuny.edu/~so...S15/hmwk3.html
here's what I'm thinking so far ...
make a 2D integer array (8 by 8) to keep track of where the knight moves (0 for not visited, 1 for visited), note that I don't like using TRUE/FALSE ... 1/0 is easier for me ...
make 2 parallel character/integer arrays (64 elemts each), so I can record the movelist, then print it) ...
so far, this is rather arbitrary stuff ... here comes the confusing part ...
let's say the person starts off at d4 ([3][3] in the 2d array), there are eight moves available ([1][2]; [5][2]; [1][4]; [5][4]; [2][5]; [2][1]; [4][5]; [5][2]), using the 2d array I can check whether or not each square was visited and cancel out the not needed squares.
here comes the first problem ... how do I keep track what and how many squares are available?
my thought: make another integer array with 8 elements and keep each available square in an integer (a1=1; a2=2; ...; a2=9; ...; h8=64 .
then I could use another formula to check every possible square and check how many moves are available there (64 at most), then return the square with the least possible solutions and return that square ...
and do this loop 63 times (63 moves) ... what do you think?
Activation? What activation?
 Originally Posted by Geekkit (from ubuntu forums regarding 'goto' statement)
Yep it sure does. So does crack cocaine. Existence is not a valid endorsement for being acceptable.
 Originally Posted by Linus Torvalds
Only wimps use tape backup: _real_ men just upload their important stuff on ftp, and let the rest of the world mirror it 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|