/*-------------------------------------------------------------------------
    program: the Yale shooting 
    file:    yale
    date:    December 97
    updated: Pablo Lopez (lopez@lcc.uma.es)
             Dept. of CS
             University of Malaga, SPAIN

    notes:   This is a Forum version of a Lygon program originally
             written by James Harland
             Lygon home page: http://www.cs.mu.oz.au/~winikoff/lygon

    sample goals:
          yale(Plan,States).
-------------------------------------------------------------------------*/

module yale.

% actions: load and shoot gun

% For each action we give a clause. The head of the clause
% contains the very action, the preconditions (required state)
% and the current plan. The body of the clause yields the
% new state and adds the action to the current plan.

linear load_gun # state(unloaded) # plan(P) *-
    state(loaded) # plan([load_gun|P]).

linear shoot_gun # state(loaded) # state(alive) # plan(P) *-
    state(dead) # state(unloaded) # plan([shoot_gun|P]).
             
% collect final states, plan and solution

final(Ss) # state(S) *- final([S|Ss]).

plan(P) # final(S) # solution(P,S).

% the problem 

yale(P,S) *-
    state(alive) # state(unloaded) #   % initial state
    load_gun # shoot_gun #             % available actions 
    plan([]) # final([]) #             % collect plan and final state
    solution(P,S).                     % get solution


