root/trunk/examples/searching/state_space.lgt

Revision 4601, 1.9 KB (checked in by pmoura, 7 weeks ago)

Added svn:mime-type property to source files (set to text/x-logtalk).

  • Property svn:mime-type set to text/x-logtalk
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1
2:- object(state_space,
3    instantiates(class),
4    specializes(object)).
5
6    :- info([
7        version is 1.1,
8        author is 'Paulo Moura',
9        date is 2008/6/9,
10        comment is 'State space description predicates.']).
11
12    :- public(initial_state/1).
13    :- mode(initial_state(?nonvar), one_or_more).
14    :- info(initial_state/1,
15        [comment is 'Initial state.',
16         argnames is ['State']]).
17
18    :- public(initial_state/2).
19    :- mode(initial_state(?atom, ?nonvar), zero_or_more).
20    :- info(initial_state/2,
21        [comment is 'Named initial state.',
22         argnames is ['Name', 'State']]).
23
24    :- public(next_state/2).
25    :- mode(next_state(+nonvar, -nonvar), zero_or_more).
26    :- info(next_state/2,
27        [comment is 'Generates a state sucessor.',
28         argnames is ['State', 'Next']]).
29
30    :- public(goal_state/1).
31    :- mode(goal_state(?nonvar), one_or_more).
32    :- info(goal_state/1,
33        [comment is 'Goal state.',
34         argnames is ['State']]).
35
36    :- public(goal_state/2).
37    :- mode(goal_state(?atom, ?nonvar), zero_or_more).
38    :- info(goal_state/2,
39        [comment is 'Named goal state.',
40         argnames is ['Name', 'State']]).
41
42    :- public(member_path/2).
43    :- mode(member_path(+nonvar, +list), zero_or_one).
44    :- info(member_path/2,
45        [comment is 'True if a state is member of a list of states.',
46         argnames is ['State', 'Path']]).
47
48    :- public(print_state/1).
49    :- mode(print_state(+nonvar), one).
50    :- info(print_state/1,
51        [comment is 'Pretty print state.',
52         argnames is ['State']]).
53
54    :- public(print_path/1).
55    :- mode(print_path(+list), one).
56    :- info(print_path/1,
57        [comment is 'Pretty print a path (list of states).',
58         argnames is ['Path']]).
59
60    initial_state(State) :-
61        ::initial_state(_, State).
62
63    goal_state(State) :-
64        ::goal_state(_, State).
65
66    print_state(State) :-
67        writeq(State), nl.
68
69    member_path(State, [State| _]) :-
70        !.
71    member_path(State, [_| Path]) :-
72        member_path(State, Path).
73
74    print_path([]).
75    print_path([State| States]) :-
76        ::print_state(State),
77        print_path(States).
78
79:- end_object.
Note: See TracBrowser for help on using the browser.