summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-03-29 01:24:01 +1100
committerJed Barber <jjbarber@y7mail.com>2014-03-29 01:24:01 +1100
commit4a4da37573d5d2b246c1ab874554cec119e45035 (patch)
tree739e3449c2a4aa2c9ae9050f366e968aa087cc06
parenta682658a67c6b02f0817058b5c5b0ecf1377a17f (diff)
Added checks for bats and pits, even though they aren't implemented yet
-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