Created
February 21, 2020 10:14
-
-
Save Anniepoo/a8743299de7f246709a3f9fdff96eb36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- module(clpfdwsc, [go/1]). | |
:-use_module(library(clpfd)). | |
go(M) :- | |
wsc([[0,0,0,0]], M), | |
flatten(M, FM), | |
label(FM). | |
wsc([[1,1,1,1]|R], [[1,1,1,1]|R]). | |
wsc([[F,W,S,C]|R], M) :- | |
[NF, NW, NS, NC] = NM, | |
NM ins 0..1, | |
NF #\= F, % move the farmer | |
% move max one thing | |
NW #= W #/\ NS #= S #\/ | |
NS #= S #/\ NC #= C #\/ | |
NW #= W #/\ NC #= C, | |
% game rules | |
NS #= NC #==> NF #= NS, | |
NW #= NS #==> NF #= NW, | |
wsc([NM, [F,W,S,C] | R], M). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment