by Melissa Dunkerley
For my final project I decided to program a robot to take care of my dog Colin.
The agent's main job is to let Colin outside in the back yard when he
wants to go out, play frisbee or ball with him when he brings one of them over
to the agent, and bring him in the house when either Colin wants to go inside,
he is barking, or he has been outside for an hour and a half. THe agent also checks
the weather and ground conditions when bringing Colin inside the house, so that if
it is raining or snowing, or if the ground is wet, the agent "locks" Colin in the
mudroom for 20 minutes to dry off, by closing the halfdoor. After 20 minutes, the
agent opens the halfdoor and lets Colin into the rest of the house.
Here are the various rules, facts and explanations that make up the domain for:
How long the dog has been in it's current location is
reset to 0 minutes, because it doesn't really matter
what the value of T2 is, as long as it is >30 when
Colin wants to go out the next morning. According to
the rules I have set, since Colin can't go out before
T1= 480 (8am) anyway, and since T1 and T2 increment
at the same rate, by the time 8am rolls around T2 will
be equal to 480, and therefore greater than 30.
The following rules apply between the hours of 8am and 10pm:
do(move(Colin, outside),T1,T2):-
is_located(Colin, house),
wants_to_be(Colin, outside),
T1 =>480, % It is after 8am
T1 =<1320, % It is before 10pm
T2 =>30. % The dog hasn't been outside in the last
% 30 minutes.
do(move(Colin, house),T1,T2):-
is_located(Colin, outside),
T2 = > 90. % Colin has been outside for 90 minutes.
do(move(Colin, house),T1,T2):-
is_located(Colin, outside),
is_barking(Colin). %Colin is barking and disturbing the
% neighbors
do(move(Colin, house),T1,T2):-
is_located(Colin, outside),
wants_to_be(Colin, house). % Colin wants to go in the house
plays_with(agent, Colin):-
is_located(Colin, outside),
brings_over(Colin, frisbee). % Colin brings the frisbee over to
% the agent, so the agent plays
% with Colin by throwing the
% frisbee.
plays_with(agent, Colin):-
is_located(Colin, outside),
brings_over(Colin, ball). % Colin brings the ball over to
% the agent, so the agent plays
% with Colin by throwing the ball.
do(close(halfdoor),T2):-
rain(weather), % lock Colin in mudroom if it is
do(move(Colin, house), T2). % raining, when he is brought in
% the house.
do(close(agent, halfdoor),T2):-
wet(ground), % lock Colin in mudroom if the
do(move(Colin,house), T2). % ground is wet, when he is
% brought in the house.
do(close(agent, halfdoor),T2):-
snow(weather), % lock Colin in mudroom if it is
do(move(Colin,house), T2). % snowing, when he is brought in
% the house.
do(open(agent, halfdoor),T2):-
dry(ground), % open the mudroom door if the
wet(ground), % ground is dry and the weather is
do(move(Colin,house),T2), % nice, but the halfdoor going
closed(halfdoor). % into the house is closed.
do(open(agent, halfdoor),T2):-
T2 is 20, % open the halfdoor if the dog has
closed(halfdoor). % been shut in the mudroom for 20
% minutes.
To Control T1 and T2:
reset(T2, 0):- % reset the "Time Colin has been
do(move(Colin,house),T1,T2). % in current location" to zero
% when he is brought in the house.
reset(T2, 0):- % reset the "Time Colin has been
do(move(Colin,outside),T1,T2). % in current location" to zero
% when he is brought outside.
reset(T1, 0):- % reset Current Time (in minutes)
T1 is 1440. % to zero at midnight.
increment(T1, T2, 1). % The agent assesses the current
% situation every minute, upon
% when it increments both T1 and T2
% by 1 minute.