Click to See Complete Forum and Search --> : help


jamescode
October 19th, 2002, 07:34 AM
help me with coding the problem of "eitht queens"not using recursion

SolarFlare
October 19th, 2002, 03:53 PM
Originally posted by jamescode
help me with coding the problem of "eitht queens"not using recursion
What is "eitht queens"?

galathaea
October 19th, 2002, 05:50 PM
You're talking about the classic problem of placing eight queens on a chess board so that none of them attack each other. Do you want all solutions or just one solution. The basic algorithm is to use a knight move as the separation. Start on an edge(row or column) and place a queen down. Now to figure where to put the queen in the next row or column next to the edge, move two steps parallel to the edge (either way) and one step perpendicular. Continue the same direction choice you made in the first step until all rows or columns (parallel to starting edge) have a queen. You need to use toroidal math, though, and wrap any moves that take you outside the board to the opposite side. This wasn't completely clear, but I hope it gives you a start.