From f59e957d741814459a0dca2993a4d3d4a2325688 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sat, 22 Mar 2014 01:02:47 +1100 Subject: Reorganising code --- agent.prolog | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'agent.prolog') diff --git a/agent.prolog b/agent.prolog index 994b77d..0c1d445 100644 --- a/agent.prolog +++ b/agent.prolog @@ -1,7 +1,24 @@ -:- module(agent, [look/0, move/1, take/1]). +:- 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), writeItemsAt(L), @@ -23,3 +40,38 @@ take(T) :- asserta(holding(T)), write('Taken.'), !. + + + +% letting the player know what's going on + +writeItemsAt(L) :- + itemAt(X,L), + description(X,D), + write(D), + fail. +writeItemsAt(_) :- true. + + +writeExits(L) :- + connects(L,_,D), + join(['You see an exit to the ',D,'.\n'],M), + write(M), + fail. +writeExits(_) :- true. + + + + +% basic facts about the maze + +itemAt(ladder,a). + + +canTake(gold). +canTake(deadWumpus). + + +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'). + -- cgit