COEN 171

                                                         Programming Languages

                                                                    Winter 2000

 

Third Programming Assignment

 

 

Problem Statement:   The assignment for this third programming problem is to again implement a solution to the 8 Queens problem, but this time using the declarative programming language Prolog.  There is no requirement related to a recursive or iterative solution, although I would expect many of the rules you write will have recursive subgoals.

 

                                    The restriction on what may be passed to the program at the top level (only the number of Queens in the past two problems) will be relaxed for this assignment.  You may, for example, pass a list with one variable for each column on the board, or some similar construct if it helps make your solution easier to obtain.

 

                                    Hand in a complete source listing for your program, as well as the results of execution indicating a correct solution to the 8 Queens problem.

 

 

Suggestions:   Again, you may find it easier to debug your programs using a smaller board (say, 4x4) simply to minimize execution time.

 

                        I have seen at least one elegant solution that uses Wirth's idea of considering the forward and backward diagonals to be lists (one element for each possible diagonal). You may want to consider this possibility.

 

                        The Prolog solution is probably NOT going to look at all like any of your previous solutions.  However, it is probable that some of the procedures and functions that you wrote for the other solutions (e.g., to check if a board position is safe) will have Prolog rules (or sets of rules) that perform the same activity.

 

                        There is no requirement for graphical (or other two-dimensional) output of your solution.  A simple list of (row, column) pairs is sufficient.

 

 

Due Date:       February 29, 2000