This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/pyswip/examples/draughts/puzzle1.pl

16 lines
342 B
Perl
Raw Normal View History

2010-06-01 00:33:32 +01:00
% This example is adapted from http://eclipse.crosscoreop.com/examples/puzzle1.pl.txt
:- use_module(library('clpfd')).
solve(Board) :-
Board = [NW,N,NE,W,E,SW,S,SE],
2012-10-08 18:27:05 +01:00
maplist(in_board(0..12), Board),
2010-06-01 00:33:32 +01:00
sum(Board, #=, 12),
NW + N + NE #= 5,
NE + E + SE #= 5,
NW + W + SW #= 5,
SW + S + SE #= 5,
label(Board).
2012-10-08 18:27:05 +01:00
in_board(D, V) :- V in D.