title: Bridge crossing puzzle with clpfd
body: <p>I have tried to solve the 'Escape from Zurg' problem with clpfd. <a href="https://web.engr.oregonstate.edu/~erwig/papers/Zurg_JFP04.pdf" rel="nofollow">https://web.engr.oregonstate.edu/~erwig/papers/Zurg_JFP04.pdf</a>
  Toys start on the left and go to the right. This is what I have:</p>
  
  <pre><code>:-use_module(library(clpfd)).
  
  toy(buzz,5).
  toy(woody,10).
  toy(res,20).
  toy(hamm,25).
  
  %two toys cross, the time is the max of the two.
  cross([A,B],Time):-
    toy(A,T1),
    toy(B,T2),
    dif(A,B),
    Time#=max(T1,T2).
  %one toy crosses
  cross(A,T):-
    toy(A,T).
  
  %Two toys travel left to right
  solve_L(Left,Right,[l_r(A,B,T)|Moves]):-
    select(A,Left,L1),
    select(B,L1,Left2),
    cross([A,B],T),
    solve_R(Left2,[A,B|Right],Moves).
  
  %One toy has to return with the flash light
  solve_R([],_,[]).
  solve_R(Left,Right,[r_l(A,empty,T)|Moves]):-
    select(A,Right,Right1),
    cross(A,T),
    solve_L([A|Left],Right1,Moves).
  
  solve(Moves,Time):-
     findall(Toy,toy(Toy,_),Toys),
     solve_L(Toys,_,Moves),
     all_times(Moves,Times),
     sum(Times,#=,Time).
  
  all_times([],[]).
  all_times(Moves,[Time|Times]):-
    Moves=[H|Tail],
    H=..[_,_,_,Time],
    all_times(Tail,Times).
  </code></pre>
  
  <p>Querying <code>?-solve(M,T)</code> or <code>?-solve(Moves,T), labeling([min(T)],[T]).</code> I get a solution but not one =&lt; 60. (I cant see one either..)
  How would I do this with clpfd? Or is it best to use the method in the link?</p>
  
  <p>FYI: I have also found this <a href="http://www.metalevel.at/zurg/zurg.html" rel="nofollow">http://www.metalevel.at/zurg/zurg.html</a>
  Which has a DCG solution. In it the constraint Time=&lt;60 is built in, it does not find the lowest time.</p>