Advertisement
Guest User

test

a guest
Jun 19th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. DOMAINS
  2. cell=c(integer,integer)
  3. list=cell*
  4. int_list=integer*
  5. PREDICATES
  6. solution(list)
  7. member(integer,int_list)
  8. nonattack(cell,list)
  9. CLAUSES
  10. solution([]).
  11. solution([c(X,Y)|Others]):-
  12. solution(Others),
  13. member(Y,[1,2,3,4,5,6,7,8]),
  14. nonattack(c(X,Y),Others).
  15. nonattack(_,[]).
  16. nonattack(c(X,Y),[c(X1,Y1)|Others]):-
  17. Y<>Y1,
  18. Y1-Y<>X1-X,
  19. Y1-Y<>X-X1,
  20. nonattack(c(X,Y),Others).
  21. member(X,[X|_]).
  22. member(X,[_|Z]):-
  23. member(X,Z).
  24. GOAL
  25. solution([c(1,1),c(2,B),c(3,C),c(4,8),c(5,E),c(6,F),c(7,G),c(8,H)]).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement