17
18:- module(ec,[abdemo_special/3]). 19
20testing_msg(X):- wdmsg(X).
21
22:- use_module(library((pfc_lib))). 23
26:- use_module(ec_common). 27
28first_d(0).
37last_d(D):- notrace(((nb_current(last_d,D),number(D))->true; D = 3000)).
38
39next_d(D1, _):- last_d(D), D1>D, !, fail.
40next_d(D1, D2):- D1<9,!,D2 is D1+3.
41next_d(D1, D2):- D1<90,!,D2 is D1+60.
42next_d(D1, D2):- D2 is D1+300.
43
44:- style_check(-singleton). 45
47abdemo_special(W,Gs,R):- \+ is_list(Gs),!, functor(Gs,F,_),!,
48 abdemo_special(W+F,[Gs],R).
49abdemo_special(loops,Gs,R):- write(cant_abdemo(loops,Gs,R)),!,nl.
50abdemo_special(_,Gs,R):- abdemo_timed(Gs,[R,N]), write_plan_len(R,N), nl, write_plan(R,[]).
51
52abdemo_special(depth(Low,High),Gs,R):-
53 b_setval(last_d,High),!,
54 abdemo_top(Gs,[[[],[]],[[],[]]],[[HA,HC],[BA,BC]],[],N,Low),
55 R = [[HA,BA],[HC,-]].
56
57abdemo_special(_,Gs,R):-
58 init_gensym(t), first_d(D), !,
59 abdemo_top(Gs,[[[],[]],[[],[]]],[[HA,HC],[BA,BC]],[],N,D),
60 write_plan_len(HA,BA),
61 R = [[HA,BA],[HC,-]].
62
63
64abdemo_top_xfrm(Gs,Gss):-
65 When = t,
66 must(fix_goal(When,Gs,Gs0)), !,
67 must(fix_time_args(When,Gs0,Gss)),!.
68
69abdemo_top(Gs,R1,R3,N1,N3,D) :-
70 must(nonvar(Gs)),
71 notrace((abdemo_top_xfrm(Gs,Gss))), Gs\=@=Gss,!,
72 abdemo_top(Gss,R1,R3,N1,N3,D).
73
74abdemo_top(Gss,R1,R3,N1,N3,D):-
75 MaxDepth = 10,
76 HighLevel = 0,
77 must(nonvar(Gss)),
78 dbginfo(all, [nl,realGoal=Gss,nl]),
79 setup_call_cleanup(
80 nb_setval(last_call_abdemo,[]),
81 abdemo_top(Gss,R1,R3,N1,N3,D, MaxDepth, HighLevel),
82 nb_setval(last_call_abdemo,[])).
83
84iv_list_to_set(List,Set):-
85 lists:number_list(List, 1, Numbered),
86 sort(1, @=<, Numbered, ONum),
87 iv_remove_dup_keys(ONum, NumSet),
88 sort(2, @=<, NumSet, ONumSet),
89 pairs_keys(ONumSet, Set).
90iv_remove_dup_keys([], []).
91iv_remove_dup_keys([H|T0], [H|T]) :-
92 H=V-_,
93 iv_remove_same_key(T0, V, T1),
94 iv_remove_dup_keys(T1, T).
95iv_remove_same_key([V1-_|T0], V, T) :-
96 V1=@=V,
97 98 !,
99 iv_remove_same_key(T0, V, T).
100iv_remove_same_key(L, _, L).
101
102ec_trace(O,0):- O=on.
103ec_trace(O,1):- O=on.
104
106
108
123:- include('planner19a.pl').
124abdemo_top(Gs,R1,R3,N1,N3,D, _MaxDepth, _HighLevel) :-
125 must(nonvar(Gs)),
126 abdemo(Gs,R1,R2,N1,N2), !,
127 abdemo_cont(R2,R3,N2,N3).
128
129:- fixup_exports.