Y1 - Y =\= Xdist, % Not upward diagonal attack % Queen does not attack any queen in Queens at horizontal distance Dist % safe(Queens): Queens is a list of Y-coordinates of non-attacking queens Figure 4.12 Program 2 for the eight-queens problem. This is from Prolog Programming for Artificial Intelligence Fourth Edition by Ivan Bratko ( WorldCat) Here is an example of a board that would would work (represented as checkDiagonals().) %check if dValue of current index is equal to Value providedįindValue(RowValue, ColumnValue, dValue) :. * checkDHelper compares the dValue against The dValue's of the other elements in the list. Passes it to checkDHelper which compares the dValue against If any two queens have the same dValue this means they are inĬheckD gets the dValue of the first element in the list and * Value is the index of H so it acts as the column value.ĭValue is the sum of H, which represents row value, and Value. * Check Diagonal and AntiDiagonal (Diagonal not implemented yet) I am new to Prolog and trying to figure out a solution to the following problem given the following guidelines: Disclaimer: The matrix is represented as a list where the number is the row and the index (1 - 8) is the column number.