# queens Test Program

The queen piece combines the power of the bishop piece and the
rook piece. Our riddle asks for the placement of eight queens so
that they donâ€™t attack each other. We have already introduced this
problem in the benchmark for the Jekejeke Runtime. We use the same
pure Prolog solution here. The solution does not represent the
whole board. Only the distinct positions of the placed queens are
remembered in a list, which makes the check for horizontal and
vertical obsolete. The diagonal check is then implemented via
arithmetic.

**Picture 13: 4 Queens**
The CLP(FD) solution resembles the pure Prolog solution. It uses
again the integer values 1..8 to represent queen positions and
imposes the horizontal and vertical conditions via a global
constraint all_distinct/1 of the constraint system. The diagonal
check is then implemented via the delayed arithmetic of the
constraint system. The backtracking through the possible solution
space if at all is then left to the constraint system.

Both solutions find the same number of solution board
configurations:

?- findall(-, queens(_), L), length(L, N).

N = 92.

?- findall(-, queens3(_), L), length(L, N).

N = 92.

For the queens test program there are the following sources:

## Comments