%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% h(STate, Goal, Value) : Value is the sum of the minutes required by
individuals or pairs out of position
h(bridge(Left, Right, _), bridge(GoalLeft, GoalRight, _), Value) :
diff_list(Left, GoalLeft, D1), high_vals(D1, V1),
diff_list(Right, GoalRight, D2), high_vals(D2, V2),
Value is V1 + V2.
diff_list([], _, []).
diff_list([HT], L, Diff) :
diff_list(T, L, TDiff),
(member(H,L), !, Diff = TDiff ; Diff = [HTDiff]).
high_vals([], 0).
high_vals([N], N).
high_vals([N1,N2T], N) :
length(T, L), high_vals(T, NT),
(L mod 2 =:= 0, !, N is NT+N2 ; N is NT+N1).
