Eight Queens Problem
The eight-queens problem is to place eight queens on a chessboard so
that no queen is attacking any other queen. The chessboard is 8x8
squares. A queen can move an unbounded number of squares: horizontally,
vertically, or diagnoally. There are several approaches one can take.
-
You can try a random brute force method. I.e. randomly attempt to
place queens on the board and then evaluate if the resulting board meets
the above criteria.
-
You can use an exhaustive brute force approach that sytematically
produces each possible configuration of queens and then evalates if the
resulting boards meet the above criteria.
-
You can attempt to produce a heuristic that will help you zone in on
a solution more directly. Some positions on the board are more likely to
eliminate more possibilites. For instance if a queen is placed at board
position (row=1, column=5), then no other queen may be placed in row 1
or column 5, eliminating 7 possibilities in each row and column. But the
associated diagonal only eliminates 3 squares. On the other hand, if a
queen is placed in row=1 and column=1, then the full diagonal is
eliminated.
|