:- dynamic dialog1/1, i_am_at/1, i_am_holding/1, at/2, prwtos_dial/1, answer1/1,a/1, b/1, lee_is/1, have_been/1, lee_at/1. dump :- listing(dialog1), listing(i_am_at), listing(i_am_holding), listing(at), listing(prwtos_dial), listing(answer1), listing(a), listing(b), listing(lee_is), listing(have_been), listing(lee_at). intro :- nl,nl, write('--- MISION II ---'),nl,nl,nl, write('After you enter the escape capsule,it automatically'),nl, write('leaves the spaceship. Just when you are meters away,'),nl, write('the spaceship blows up. The explosion looks extremely'),nl, write('bright with the black blank space as the background.'),nl,nl, write('You can see just ahead of you the new artificial moon '),nl, write('of Venus. The capsule is programmed to land on the '),nl, write('nearest surface, hence it is headed that way.'),nl,nl, write('After a few hours\' of travel, the capsule lands safely '),nl, write('on the surface and its door opens for you to step out.'),nl,nl,nl, write('TIP -- Type ''step_out.'' to step out.'),nl,nl,nl,retractall(i_am_at(_)), asserta(i_am_at(capsule)),db,asserta(have_been(nooo)),asserta(lee_at(school)), asserta(prwtos_dial(1)). db:-['db1.txt']. :- intro. at(book,police). step_out :- write('The lid opens and you slowly climb out of the capsule.'),nl,nl, retract(i_am_at(capsule)), asserta(i_am_at(mountain_top)), look. look :- i_am_at(Place),describe(Place),map1(Place). /* Περιγραφές */ describe(mountain_top) :- write('You can see that you are on the top of a mountain.'),nl, write('The mountain top is covered in snow, and the temperature'),nl, write('seems to be below freezing. Your breath is white cold '),nl, write('and it seems ready to freeze in mid air. You are not dressed'),nl, write('for these kind of conditions. Space is cold, but this is'),nl, write('a whole different kind of cold; a freezing your mustache off cold.'),nl,nl, write('At the foot of the mountain you can see an industrial city.'),nl, write('The city lights are not that visible through the cold haze, but'),nl, write('the city seems to be small from what you can make out.'),nl,nl, write('The cliff seems easy to climb down; it\'s not steep and it\'s'),nl, write('not yet frozen. Better get out of here before you freeze to death.'),nl,nl, write('TIP -- Type ''climb(down).'' to climb down.'). describe(outskirts) :- write('You are in the outskirts of the small industrial city.'),nl, write('This part of the city seems pretty busy for the outskirts.'),nl, write('A lot of people come and go, but not a single being pays '),nl, write('the slightest attention to you. In front of you, you can '),nl, write('see the main road of the town.'),nl,nl, write('TIP -- Type ''up./down./left./right.'' to move'). describe(center) :- write('You are in the center of the city. The usual city hustle bustle '),nl, write('is all around you. People are to be seen everywhere here; they '),nl, write('come and go without the slightest hesitation on their paths.'),nl, write('Despite the numerous people that come and go all over the place,'),nl, write('the buildings seem abandonded. Most of them seem ran down, like'),nl, write('some kind of war has recently ended and noone took care of the buildings.'),nl,nl, write('TIP -- Type ''enter(building).'' to enter a building.'). describe(police) :- write('You entered the Police Station, but it appears '),nl, write('to be empty. The place looks abandonded for years.'),nl, write('It seems like no one has stepped a foot in here for '),nl, write('quite some time, which is weird for such a busy city.'),nl,nl, write('TIP -- When you are in a room, type ''examine.'''),nl, write('to examine it.'),nl, write('TIP -- To exit a building, type ''down.'''). describe(school) :- write('The school seems abandonded like the rest of the buildings.'),nl. /* Αναλυτικές Περιγραφές*/ explicit-desc(police):- write('The cells are empty, the doors are open and'),nl, write('seem violated. As you get closer to the cells,'),nl, write('you can see that there is a body under each bed.'),nl,nl, write('As you look closer, you see that one of the corpses'),nl, write('is holding a book.'),nl. explicit-desc(school):- write('Nothing special here.'),nl. explicit-desc(center):- write('This isn''t a room.'),nl. explicit-desc(outskirts):- write('This isn''t a room.'),nl. /* Σκαρφαλώματα */ climb(down) :- i_am_at(mountain_top), retract(i_am_at(mountain_top)), asserta(i_am_at(outskirts)), look,!. climb(down) :- \+ i_am_at(mountain_top), write('Climb down what?'). climb(up) :- i_am_at(outskirts), retract(i_am_at(outskirts)), asserta(i_am_at(mountain_top)), look,!. climb(up) :- \+ i_am_at(outskirts), write('Climb what?'),!. climb(_) :- write('What?'),nl,!. /* Χάρτες */ map1(mountain_top) :-nl,nl,write('mountain'),nl, write(' top'),nl,nl, write('*******'),nl, write('********'),nl, write('*********'),nl, write('****** c *'),nl, write('******* l *'),nl, write('******** i *'),nl, write('********* f *'),nl, write('********** f *'),nl, write('***************'),nl, write('****************'),nl, write('***************** city'),nl,nl. map1(outskirts) :- nl,nl,write(' | City | '),nl, write(' |center | '),nl, write(' | |'),nl, write(' | |________'),nl, write('________|'),nl,nl, write('--------| |--------'),nl, write(' | |'),nl, write(' | |'),nl, write(' | |'),nl, write('________| |'),nl, write(' Main |'),nl, write('--------| Road |'),nl, write(' | |___________'),nl, write('________|'),nl, write(' outskirts'),nl,nl. map1(center) :- nl,nl,write(' Desert'),nl,nl, write('Construction | |'),nl, write(' | |House'),nl, write(' | |_________'),nl, write(' |'),nl, write('_____________| '),nl, write(' ____________'),nl, write('____________ |'),nl, write(' | Main | Police'),nl, write('Construction| Road |'),nl, write(' | |___________'),nl, write(' |'),nl, write(' | _____________'),nl, write('____________| |'),nl, write(' |'),nl, write(' | School'),nl, write('__________ |'),nl, write(' | |'),nl, write('House | |'),nl, write(' | |____________'),nl, write('__________|'),nl,nl, write(' Outskirts'),nl,nl. map1(police) :- nl,nl,write(' | | |'),nl, write(' | | |'),nl, write(' Cell | Cell | Cell |'),nl, write(' | | |'),nl, write('___/____|___/___|___/___|'),nl, write(' |'),nl, write(' |'),nl, write(' |'),nl, write(' |'),nl, write(' Office |'),nl, write(' |'),nl, write(' |'),nl, write(' |'),nl, write('___________/ \\__________|'),nl,nl. map1(school):-write('It is pretty small, just one room.'),nl. /* Πως συνδέονται οι περιοχές */ monopati(outskirts,up,center). monopati(center,down,outskirts). monopati(center,up,desert). monopati(police,down,center). monopati(desert,down,center). monopati(school,down,center). /* Μετακίνηση */ up :- go(up). down :- go(down). left :- go(left). right :- go(right). go(down) :- i_am_at(outskirts), write('The freezing cold mountain is that way. You cannot simply'),nl, write('walk to the mountain. You have to climb up the cliff.'),nl,nl,!. go(down):- i_am_at(school), write('As soon as you exit the school,'),nl, write('you see that the top of the mountain is ablaze.'),nl, write('''OH NO'' Lee says in despair.'),finito,!. go(up):- i_am_at(center), write('You don''t want to go there.'),nl, write('(yet)'),nl,!. go(Direction) :- i_am_at(Here), monopati(Here, Direction, There), retractall(i_am_at(Here)), asserta(i_am_at(There)),look,!. go(_) :- write('There is nothing that way.'). /* Που μπορεί να μπει */ enter(X):- i_am_at(X), write('You are already here.'). enter(police) :- i_am_at(center), retract(i_am_at(center)), asserta(i_am_at(police)),look,asserta(have_been(police)),!. enter(police) :- \+ i_am_at(center), write('That''s not here.'),nl. enter(house) :- \+ i_am_at(center), write('That''s not here.'),nl. enter(house) :- i_am_at(center), write('That''s illegal. Shame on you.'),nl,!. enter(construction) :- \+ i_am_at(center), write('That''s not here.'),nl. enter(construction) :- i_am_at(center), write('That''s not safe.'),nl,!. enter(school) :- \+ i_am_at(center), write('That''s not here.'),nl. enter(school) :- i_am_at(center), \+ have_been(police), \+i_am_holding(book), write('Maybe you should go to the police first.'),nl,!. enter(school) :- i_am_at(center), have_been(police), \+i_am_holding(book), write('Maybe you should go to the police again.'),nl,!. enter(school) :- i_am_at(center), \+ lee_at(school), retract(i_am_at(center)), asserta(i_am_at(school)),look. enter(school) :- i_am_at(center),lee_at(school), retract(i_am_at(center)), asserta(i_am_at(school)),look,o_lee_school,!. enter(_) :- write('You can''t enter that.'),nl. /* Το o_lee_school είναι για να ξέρουμε αν είναι η πρώτη φορά που ο χρήστης μπαίνει στο σχολειο, δηλαδή αν ο λι είναι στο σχολείο. Γιατί μετά φεύγει.*/ o_lee_school :- write('As you look around the room, you see a person sitting '),nl, write('on a desk looking at you behind the shadows.'),nl,dialog1(1). /* Διάλογοι */ dialog1(1):- nl,write('''Well, howdy there neighbour! How are ya?'),nl, write('What''s my name? My name is Lee.'),nl, write('I live on that cliff, aka the Van Cliff.'),nl, write('What brings you here?'''),nl,answer1(1). answer1(1):- nl,write('(Choose one of the answers below:)'),nl,write('a: My spaceship blew up!'),nl, write('b: That''s my business.'),nl, asserta((a:-write('''Really? When? How?'''),answer_a1)), asserta((b:-write('''Sorry mate, didn''t mean to intrude.'''),answer_b1)). answer_a1:- nl,retractall(a),retractall(b),retractall(lee_is(_)),asserta(lee_is(happy)), write('''Like an hour ago.'''), nl,write('''Where? Is everyone okay?'''),nl, nl,write('a: It was just me on the spaceship.'), nl,write('b: Yeah,all of us are alive.'), asserta((a:-write('''Where did you crash?'''),answer_a2)), asserta((b:-write('He looks at you skeptical'),answer_b2)). answer_b1:- nl,retractall(a),retractall(b),retractall(lee_is(_)),asserta(lee_is(annoyed)), write('Lee looks at you for a long moment'),nl, write('and then leaves the building.'),nl. answer_a2:- nl,retractall(a),retractall(b),asserta(lee_is(happy)), write('''On top of the Van Cliff.'''),nl, write('''That''s not good. Let''s go there now.'''),nl, write('He says as he exits the building'),retract(lee_at(school)), asserta(lee_at(center)). answer_b2:- nl,retractall(a),retractall(b),retractall(lee_is(_)),asserta(lee_is(sceptical)), write('''Let''s go find your spaceship.'''),nl, write('He says as he exits the building.'),retract(lee_at(school)), asserta(lee_at(center)),!. /* Πως μπορεί ο χρήστης να πάρει ένα αντικείμενο */ take(X) :- i_am_holding(X), write('You''re already holding it!'), nl. take(X) :- i_am_at(A), retract(at(X,A)), write('You picked up '), write(X), write('.'), nl, asserta(i_am_holding(X)), perigrafi_object(X),!. take(_):-write('I don''t see it here.'),nl. perigrafi_object(book):-write('The book is a really old hardcover.'),nl, write('The title is smudged, but it looks '),nl, write('like it says \'Decipher Book\' '),nl,nl, write('TIP -- To read the book, type \'read_book.\'.'),nl. read_book:- write('This is a book about deciphering codes.'). examine:- i_am_at(X),explicit-desc(X),!. inventory:- \+ i_am_holding(_), write('You aren''t holding anything!'),nl. inventory:- i_am_holding(X), write('You are holding '),write(X),write('.'),nl. help :- instructions. instructions :- nl,nl,write('Must use standard Prolog Syntax.'),nl,nl, write('\t MOVEMENT'),nl, write('\t up. -- go up.'),nl, write('\t down. -- go down.'),nl, write('\t left. -- go left.'),nl, write('\t right. -- go right.'),nl,nl, write('\t PICKING UP OBJECTS'),nl, write('\t take(object). -- pick up object.'),nl,nl, write('\t DROPPING OBJECTS'),nl, write('\t drop(object). -- drop object'),nl,nl, write('\t INVENTORY'),nl, write('\t inventory. -- shows your inventory.'),nl,nl, write('\t THE ROOM'),nl, write('\t look. -- describes the room.'),nl,nl, write('\t HELP'),nl, write('\t help. -- shows instructions.'),nl, write('\t instructions. -- shows instructions.'),nl,nl. finito:- nl,nl,write('Mission Complete!'),db1. db1:-tell('db2.txt'),listing(i_am_holding),listing(lee_is),told.