From 4a4da37573d5d2b246c1ab874554cec119e45035 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sat, 29 Mar 2014 01:24:01 +1100 Subject: Added checks for bats and pits, even though they aren't implemented yet --- agent.prolog | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) 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 -- cgit