summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--agent.prolog52
1 files changed, 30 insertions, 22 deletions
diff --git a/agent.prolog b/agent.prolog
index 0c1d445..37ebd3c 100644
--- a/agent.prolog
+++ b/agent.prolog
@@ -21,7 +21,7 @@ init :-
look :-
here(L),
- writeItemsAt(L),
+ writeSenses(L),
writeExits(L).
@@ -29,7 +29,9 @@ move(D) :-
here(L),
connects(L,N,D),
retract(here(L)),
- asserta(here(N)), !.
+ asserta(here(N)),
+ join(['You move to the ',D,' .\n\n'],M),
+ write(M), !.
take(T) :-
@@ -38,40 +40,46 @@ take(T) :-
canTake(T),
retract(itemAt(T,L)),
asserta(holding(T)),
- write('Taken.'), !.
+ write('Taken.\n\n'), !.
% letting the player know what's going on
-writeItemsAt(L) :-
- itemAt(X,L),
- description(X,D),
- write(D),
- fail.
-writeItemsAt(_) :- true.
+writeSenses(L) :-
+ glitter(L),
+ breeze(L),
+ bats(L),
+ stench(L).
-writeExits(L) :-
- connects(L,_,D),
- join(['You see an exit to the ',D,'.\n'],M),
- write(M),
- fail.
-writeExits(_) :- true.
-
+glitter(L) :-
+ goldAt(L),
+ write('You see a glitter along the sandy floor of the cave.\n').
+breeze(L) :-
+ connects(L,X,_),
+ pitAt(X),
+ write('A cold breeze blows through the room, making you shiver slightly.\n').
-% basic facts about the maze
-itemAt(ladder,a).
+bats(L) :-
+ connects(L,X,_),
+ batsAt(X),
+ write('All available surfaces are covered in guano. How unsanitary.\n').
-canTake(gold).
-canTake(deadWumpus).
+stench(L) :-
+ connects(L,X,_),
+ wumpusAt(X),
+ write('An overpowering stench fills your nose.\n').
-description(ladder, 'There is a rope ladder hanging from the ceiling here.\n').
-description(gold, 'You see a glitter along the sandy floor of the cave.\n').
+writeExits(L) :-
+ findall(X, connects(L,_,X), E),
+ intercalate(E, ', ', O),
+ join(['There are exits to the ',O,'.\n'],W),
+ write(W).