% representation of the board % col(.) and row(.) as in the queen example % bad(.) for damaged cell % ntiles is a constant for the number of tiles col(1..n). row(1..n). tile(1..ntiles). bad(1,1). bad(3,2). 1 {cell(I,J,T) : tile(T) } 1 :- col(I), row(J), not bad(I,J). % constraint checking % one tiles cannot cover more than two cells :- tile(T), cell(I1,J1,T), cell(I2,J2,T), cell(I3,J3,T), col(I1), col(I2), col(I3), row(J1), row(J2), row(J3), I1 > I2, I2 > I3. :- tile(T), cell(I1,J1,T), cell(I2,J2,T), cell(I3,J3,T), col(I1), col(I2), col(I3), row(J1), row(J2), row(J3), I1 = I2, J1 > J2, I2 > I3. :- tile(T), cell(I1,J1,T), cell(I2,J2,T), cell(I3,J3,T), col(I1), col(I2), col(I3), row(J1), row(J2), row(J3), I1 = I2, J1 > J2, I3 > I2. :- tile(T), cell(I1,J1,T), cell(I2,J2,T), cell(I3,J3,T), col(I1), col(I2), col(I3), row(J1), row(J2), row(J3), I1 = I2, I2 = I3, J1 > J2, J2 > J3. % one tile cannot cover only one cell % do we need it (?) % cell covered by the same tile must be neightbor % (not far from each other) :- tile(T), cell(I1,J1,T), cell(I2,J2,T), col(I1), col(I2), row(J1), row(J2), I1 - I2 > 1. :- tile(T), cell(I1,J1,T), cell(I2,J2,T), col(I1), col(I2), row(J1), row(J2), J1 - J2 > 1. % they cannot be on a diagonal :- tile(T), cell(I1,J1,T), cell(I2,J2,T), col(I1), col(I2), row(J1), row(J2), neq(I1,I2), neq(J1,J2). hide row(_). hide col(_). hide tile(_). hide bad(_,_).