dynamic( [im_at/1, door/1]).
im_at(car).
door(false).
/* Facts*/
path(car,forward,gasstation):-
door(true),write('Wellcome to Gas Station'),nl,
write('You can buy a newspaper or a drink!').
path(car,forward,gasstation):-
write('You need to open the Car door '),nl,
!,fail.
path(gasstation,back,car):-
door(true),write('You got back in the car'),nl.
path(gasstation,back,car):-
write('You need to open the car door'),nl.
open_cardoor:-
door(true),
write('You already opend the door!'),
nl, !.
open_cardoor:-
im_at(car),
assertz(door(true)),
retract(door(false)),nl,
write('You openned the car door!'),nl,!.
forward:-go(forward).
back:-go(back).
go(Direction) :-
im_at(Here),
path(Here, Direction, There),
retract(im_at(Here)),
assert(im_at(There)),
!.
buy(drink) :-
im_at(gasstation),
write('Added a drink to bag.'), nl,
!.
buy(newspaper) :-
im_at(gasstation),
write('Added a newspaper to bag.'), nl,
!.
buy(_):-
write('You need to go to Gas Station to buy!'),nl.
start:- write('All that driving made me thirsty, you?'),nl.