diff options
author | Jed Barber <jjbarber@y7mail.com> | 2014-03-28 19:27:21 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2014-03-28 19:27:21 +1100 |
commit | 52cc6731410d9862105b987bd0fa6ae819bab363 (patch) | |
tree | 35a3a9f0e72f8d6b16c038270d74a413b6f349fc | |
parent | 84b3b5d3efe7e33aeea4243c04436ce2a9a845d5 (diff) |
More initialisation work
-rw-r--r-- | agent.prolog | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/agent.prolog b/agent.prolog index 37ebd3c..3a189bb 100644 --- a/agent.prolog +++ b/agent.prolog @@ -11,8 +11,36 @@ % initialisation init :- + initPos, + initPits, + initWumpus, + initGold, + initBats, !. + + +initPos :- + roomList(R), + random_member(X,R), retractall(here(_)), - asserta(here(a)), !. + not(somethingAt(X)), + asserta(here(X)). + + +initPits :- true. + + +initWumpus :- + roomList(R), + random_member(X,R), + retractall(wumpusAt(_)), + not(somethingAt(X)), + asserta(wumpusAt(X)). + + +initGold :- true. + + +initBats :- true. @@ -54,23 +82,27 @@ writeSenses(L) :- stench(L). +glitter(_) :- not(current_predicate(goldAt/1)). glitter(L) :- goldAt(L), write('You see a glitter along the sandy floor of the cave.\n'). +breeze(_) :- not(current_predicate(pitAt/1)). breeze(L) :- connects(L,X,_), pitAt(X), write('A cold breeze blows through the room, making you shiver slightly.\n'). +bats(_) :- not(current_predicate(batsAt/1)). bats(L) :- connects(L,X,_), batsAt(X), write('All available surfaces are covered in guano. How unsanitary.\n'). +stench(_) :- not(current_predicate(wumpusAt/1)). stench(L) :- connects(L,X,_), wumpusAt(X), @@ -83,3 +115,17 @@ writeExits(L) :- join(['There are exits to the ',O,'.\n'],W), write(W). + + + +% miscellaneous clauses + +somethingAt(X) :- current_predicate(here/1), here(X). +somethingAt(X) :- current_predicate(wumpusAt/1), wumpusAt(X). +somethingAt(X) :- current_predicate(pitAt/1), pitAt(X). +somethingAt(X) :- current_predicate(goldAt/1), goldAt(X). +somethingAt(X) :- current_predicate(batsAt/1), batsAt(X). + + +intercalate(I,S,O) :- O is I. + |