%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%					%
% Artificial Intelligence Project	%
% Fall 1999				%
%					%
% by Margit Lang			%
% 					%
%                                    	%
%                                    	%
% Domain & Actions for Housekeeping    	%
%					%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% for the "house"

% static worlddescribtion:

% room(X)-> X is a room.
% door(X,Y) -> there is a door between X and Y
% connected(X,Y) -> X and Y are connected rooms
% container(X) -> X is a container

%dynamic attributes
% at(X) -> the robot is currently in the room X
% in(X,Y) -> Thing X is in room Y
% have(X) ->the robot is holding thing X
% open(X,Y) -> door between room X and room Y is open
% closed(X,Y) -> door(X,Y) is closed
% dusty_floor(X) -> the floor in room(X) is dusty
% clean_floor(X) -> the floor in room(X) is clean
% full(X) -> container(X) is full
% empty(X) -> container X is empty
% dusty(Room) -> Room is dusty
% clean(Room) -> Room is clean
% noone_sleeps(Room) -> nobody is currently sleeping in Room
% sleeps(Room) -> there is somebody sleeping in Room.
% ready(Something) -> Something is ready, e.g. the meal,..



room(kitchen).
room(bedroom).
room(bathroom).
room(livingroom).
room(diningroom).

door(kitchen,livingroom).
door(livingroom,bathroom).
door(livingroom,bedroom).
door(livingroom,diningroom).


container(vacuum).
container(bottle).
container(trashcan).
container(dishwasher).

connected(X,Y):- door(X,Y).
connected(X,Y):- door(Y,X).


%Initialstate =[dusty_floor(bathroom),in(vacuum,bedroom),empty(vacuum),closed(livingroom,diningroom),closed(diningroom,livingroom),closed(kitchen,livingroom),closed(livingroom,kitchen),closed(livingroom,bathroom),closed(bathroom,livingroom),closed(livingroom,bedroom),closed(bedroom,livingroom),at(bedroom),dusty(bedroom),sleeping(bedroom),dirty(dishes),full(dishwasher),in(duster,livingroom)]
%Goal1=[at(kitchen)]
%Goal2=[cleaned_floor(bathroom)]
  
% 2) go(From,To) :- the robot goes from From to To 
	can(go(From,To),[at(From),open(From,To)]):- connected(From,To). 
	add(go(From,To),[at(To)]). 
	del(go(From,To),[at(From)]). 

% 3) pick_up(What):- picks What up 
	can(pick_up(What),[in(What,Where), at(Where)]):-room(Where). 
	add(pick_up(What),[have(What)]). 
	del(pick_up(What),[in(What,Where)]). 

% 4) open_door(From,To):- the robot opens the door between room From and room To
	can(open_door(From,To),[at(From),closed(From,To)]):- connected(From,To).
	add(open_door(From,To),[open(From,To),open(To,From)]).
	del(open_door(From,To),[closed(From,To),closed(To,From)]).

%5) close_door(From,To):- the robot closes the door between From and To
	can(close_door(From,To),[at(From),open(From,To)]).
	add(close_door(From,To),[closed(From,To),closed(To,From)]).
	del(close_door(From,To),[open(From,To),open(To,From)]).

%6) clean_floor(Room) :- robot cleans the floor in Room
	can(clean_floor(Room),[at(Room),have(vacuum),empty(vacuum)]).
	add(clean_floor(Room) ,[clean_floor(Room),full(vacuum)]).
	del(clean_floor(Room) ,[dusty_floor(Room),empty(vacuum)]).

%7) empty(What):- the robot empties the What
	can(empty(What),[full(What)]):- container(What).
	add(empty(What),[empty(What)]).
	del(empty(What),[full(What)]).

%8) wipe_dust(Room) :- the robot wipes the dust in the Room
	can(wipe_dust(Room),[at(Room),have(duster),dusty(Room)]).
	add(wipe_dust(Room),[dusty_floor(Room),clean(Room)]).
	del(wipe_dust(Room),[dusty(Room)]).

%9) tidy_bed(Room) :- robot tidies up the bed in the room Room
	can(tidy_bed(Room), [noone_sleeps(Room), bed_mess(Room), at(Room)]).
	add(tidy_bed(Room), [bed_tidy(Room)]).
	del(tidy_bed(Room), [bed_mess(Room)]).

%10) wake_up(Room) :- robot wakes the persons, who are sleeping in room Room
	can(wake_up(Room),[sleeps(Room), at(Room)]).
	add(wake_up(Room),[noone_sleeps(Room), bed_mess(Room)]).
	del(wake_up(Room),[sleeps(Room)]).

	 
%11) do_dishes :- robot does the dishes
	can(do_dishes,[dirty(dishes),empty(dishwasher),at(kitchen)]).
	add(do_dishes,[clean(dishes),full(dishwasher)]).
	del(do_dishes,[dirty(dishwasher),empty(dishwasher)]).

%12) cook :- robot cooks something
	can(cook,[clean(dishes), at(kitchen), have(ingredients)]).
	add(cook,[dirty(dishes), ready(meal), in(meal,kitchen)]).
	del(cook,[clean(dishes),have(ingredients)]).

%13) serve :- robot serves the meal to its master
	can(serve,[ready(meal),at(diningroom),have(meal)]).
	add(serve,[satisfied(master)]).
	del(serve,[ready(meal),have(meal)]).



