TYPE
BoardSize = SHORTINT; (* [1..maxn] *)
Position = SHORTINT; (* [0..n-1] *)
Board =
RECORD
size: BoardSize; (* square size *)
nofqueens: SHORTINT; (* [0..n], # of queens set *)
pos: ARRAY maxn OF RECORD row, col: Position END;
(* queen positions for [0..nofqueens-1] *)
(* a queen on (row, col) threatens a row, a column,
and 2 diagonals;
rows and columns are characterized by
their number (0..n-1),
the diagonals by row-col+n-1 and row+col,
(n is a shorthand for board.size)
*)
rows: SET; (* OF [0..n-1] *)
cols: SET; (* OF [0..n-1] *)
diags1: SET;
(* OF [0..2*(n-1)] -- used for row-col+n-1 *)
diags2: SET;
(* OF [0..2*(n-1)] -- used for row+col *)
END;
|