summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--agent.prolog32
1 files changed, 31 insertions, 1 deletions
diff --git a/agent.prolog b/agent.prolog
index a0c4289..b2704a5 100644
--- a/agent.prolog
+++ b/agent.prolog
@@ -152,16 +152,40 @@ moveWumpus :-
checkHazards :-
- checkWumpus.
+ checkWumpus,
+ checkBats,
+ checkPit.
checkWumpus :-
+ current_predicate(wumpusAt/1),
here(Location),
wumpusAt(Location),
lose(eaten).
checkWumpus :- true.
+checkBats :-
+ current_predicate(batsAt/1),
+ here(Location),
+ batsAt(Location),
+ write('A giant bat swoops down, picks you up, and deposits you elsewhere in the cave.\n\n'),
+ roomList(Rooms),
+ filter(Rooms, somethingAt, emptyRooms),
+ random_member(NewLocation, emptyRooms),
+ retract(here(Location)),
+ asserta(here(NewLocation)).
+checkBats :- true.
+
+
+checkPit :-
+ current_predicate(pitAt/1),
+ here(Location),
+ pitAt(Location),
+ lose(pit).
+checkPit :- true.
+
+
% winning, losing, and otherwise
@@ -177,6 +201,12 @@ lose(eaten) :-
halt(0).
+lose(pit) :-
+ write('You have fallen into a bottomless pit.\n'),
+ write('*** GAME OVER ***\n'),
+ halt(0).
+
+
% miscellaneous clauses