From 3a9d367a7b6a589006c7b59ee3399cf3434e2b99 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Thu, 27 Mar 2014 03:44:00 +1100 Subject: Improved sensory clauses --- agent.prolog | 52 ++++++++++++++++++++++++++++++---------------------- 1 file 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). -- cgit