summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/agent.prolog22
-rw-r--r--src/main.prolog1
2 files changed, 11 insertions, 12 deletions
diff --git a/src/agent.prolog b/src/agent.prolog
index 4085bf9..0b8ed3e 100644
--- a/src/agent.prolog
+++ b/src/agent.prolog
@@ -12,6 +12,11 @@
% initialisation
init :-
+ retractall(here(_)),
+ retractall(pitAt(_)),
+ retractall(wumpusAt(_)),
+ retractall(goldAt(_)),
+ retractall(batsAt(_)),
initPos,
initPits,
initWumpus,
@@ -25,20 +30,16 @@ init :-
initPos :-
retractall(moves(_)),
asserta(moves(0)),
- retractall(here(_)),
roomList(Rooms),
filter(Rooms, somethingAt, Emptyrooms),
random_member(X,Emptyrooms),
asserta(here(X)).
-initPits :-
- retractall(pitAt(_)),
- insert(5,pitAt).
+initPits :- insert(4,pitAt).
initWumpus :-
- retractall(wumpusAt(_)),
roomList(Rooms),
filter(Rooms, somethingAt, Emptyrooms),
random_member(X,Emptyrooms),
@@ -46,15 +47,12 @@ initWumpus :-
initGold :-
- retractall(goldAt(_)),
retractall(haveGold(_)),
insert(3,goldAt),
asserta(haveGold(0)).
-initBats :-
- retractall(batsAt(_)),
- insert(2,batsAt).
+initBats :- insert(2,batsAt).
insert(N,Thing) :-
@@ -179,7 +177,7 @@ stench(_) :- true.
writeExits(Location) :-
findall(X, connects(Location,_,X), Exits),
intercalate(Exits, ', ', O),
- join(['There are exits to the ',O,'.\n'],W),
+ join(['There are exits to the ',O,'.\n\n'],W),
write(W).
@@ -252,13 +250,13 @@ win :-
lose(eaten) :-
- write('You have been eaten by the wumpus.\n'),
+ write('You have been eaten by the wumpus.\n\n'),
write('*** GAME OVER ***\n'),
halt(0).
lose(pit) :-
- write('You have fallen into a bottomless pit.\n'),
+ write('You have fallen into a bottomless pit.\n\n'),
write('*** GAME OVER ***\n'),
halt(0).
diff --git a/src/main.prolog b/src/main.prolog
index ef23f4f..09011ed 100644
--- a/src/main.prolog
+++ b/src/main.prolog
@@ -8,6 +8,7 @@
play :-
+ write('\n\nHUNT THE WUMPUS\n\n\n'),
init,
look,
playLoop.