AI-Prolog

 view release on metacpan or  search on metacpan

data/spider.pro  view on Meta::CPAN


instructions :-
        nl,
        print('Enter commands using standard Prolog syntax.'), nl,
        print('Available commands are:'), nl,
        print('start.                   -- to start the game.'), nl,
        print('n.  s.  e.  w.  u.  d.   -- to go in that direction.'), nl,
        print('take(Object).            -- to pick up an object.'), nl,
        print('drop(Object).            -- to put down an object.'), nl,
        print('kill.                    -- to attack an enemy.'), nl,
        print('look.                    -- to look around you again.'), nl,
        print('instructions.            -- to see this message again.'), nl,
        print('halt.                    -- to end the game and quit.'), nl,
        nl.


% This rule prints out instructions and tells where you are.

start :-
        instructions,
        look.


% These rules describe the various rooms.  Depending on
% circumstances, a room may have more than one description.

describe(meadow) :-
        at(ruby, in_hand),
        print('Congratulations!!  You have recovered the ruby'), nl,
        print('and won the game.'), nl,
        finish.

describe(meadow) :-
        print('You are in a meadow.  To the north is the dark mouth'), nl,
        print('of a cave; to the south is a small building.  Your'), nl,
        print('assignment, should you decide to accept it, is to'), nl,
        print('recover the famed Bar-Abzad ruby and return it to'), nl,
        print('this meadow.'), nl.

describe(building) :-
        print('You are in a small building.  The exit is to the north.'), nl,
        print('There is a barred door to the west, but it seems to be'), nl,
        print('unlocked.  There is a smaller door to the east.'), nl.

describe(cage) :-
        print('You are in a den of the lion!  The lion has a lean and'), nl,
        print('hungry look.  You better get out of here!'), nl.

describe(closet) :-
        print('This is nothing but an old storage closet.'), nl.

describe(cave_entrance) :-
        print('You are in the mouth of a dank cave.  The exit is to'), nl,
        print('the south; there is a large, dark, round passage to'), nl,
        print('the east.'), nl.

describe(cave) :-
        alive(spider),
        at(ruby, in_hand),
        print('The spider sees you with the ruby and attacks!!!'), nl,
        print('    ...it is over in seconds....'), nl,
        die.

describe(cave) :-
        alive(spider),
        print('There is a giant spider here!  One hairy leg, about the'), nl,
        print('size of a telephone pole, is directly in front of you!'), nl,
        print('I would advise you to leave promptly and quietly....'), nl.

describe(cave) :-
        print('Yecch!  There is a giant spider here, twitching.'), nl.

describe(spider) :-
        alive(spider),
        print('You are on top of a giant spider, standing in a rough'), nl,
        print('mat of coarse hair.  The smell is awful.'), nl.

describe(spider) :-
        print('Oh, gross!  You are on top of a giant dead spider!'), nl.



( run in 0.613 second using v1.01-cache-2.11-cpan-39bf76dae61 )