:- module(agent, [init, look/0, move/1, take/1]). :- consult('parser.prolog'). :- consult('map.prolog'). % initialisation init :- retractall(here(_)), asserta(here(a)), !. % command functions look :- here(L), writeSenses(L), writeExits(L). move(D) :- here(L), connects(L,N,D), retract(here(L)), asserta(here(N)), join(['You move to the ',D,' .\n\n'],M), write(M), !. take(T) :- here(L), itemAt(T,L), canTake(T), retract(itemAt(T,L)), asserta(holding(T)), write('Taken.\n\n'), !. % letting the player know what's going on writeSenses(L) :- glitter(L), breeze(L), bats(L), stench(L). 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'). bats(L) :- connects(L,X,_), batsAt(X), write('All available surfaces are covered in guano. How unsanitary.\n'). stench(L) :- connects(L,X,_), wumpusAt(X), write('An overpowering stench fills your nose.\n'). writeExits(L) :- findall(X, connects(L,_,X), E), intercalate(E, ', ', O), join(['There are exits to the ',O,'.\n'],W), write(W).