Guest User

Untitled

a guest
Dec 7th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 5.07 KB | None | 0 0
  1. %AREAS
  2.  
  3. location(cornfield, 'A burned up cornfield, reeking of smoke and fumes. The rain put out this mighty blaze. \nTo the south is the pumpkin_patch.').
  4.  
  5. location(pumpkin_patch, 'You find yourself in a small, tidy field of pumpkins. You take cover under a small tent to get out of the rain. \nPeering North you can see smoke over the trees. To the West you see a creaky old barn. \nTo the East you can barely make out a beaten path going into the woods. To the South there is an empty field.').
  6.  
  7. location(old_barn, 'You see a rickety old barn. The shudders are loudly creaking in the wind. \nThere is a creaky old house to the West, and a pumpkin patch to the East.').
  8.  
  9. location(house, 'You find yourself at an old house. \nYou see evidence of a powerful thunderstorm overhead. \nTo the East you see an old barn.').
  10.  
  11. location(beaten_path, 'A long and winding road, heading further to the east. \nYou hear cars coming from the East. Back to the West you see the pumpkin patch.').
  12.  
  13. location(main_road, 'You are at the main road into town. Every so often you see a large truck pass by without even noticing you.').
  14.  
  15. location(empty_fields, 'You find yourself in an empty field. The ground looks barren and dark. \nFurther South you can make out what looks to be a long abandoned Church. To the North you see the pumpkin patch.').
  16.  
  17. location(church, 'A dark, looming church stands here. A weaker person may have fled from the sight. \nTo the North is the fields, and to the South is a foreboding graveyard.').
  18.  
  19. location(cemetary, 'You are in a gloomy cemetary. The ground below you shifts and trembles almost as if it is alive. \nTo the North is the abandoned church.').
  20.  
  21. location(haystack, 'You are at the bottom of a ten foot haystack.').
  22.  
  23. location(nest, 'You find a giant birds nest. Huh, weird.').
  24.  
  25. %PLAYER
  26.  
  27. where(house).
  28. back(thevoid).
  29.  
  30.  
  31. %DOORS
  32.  
  33. door(house, old_barn,beside).
  34. door(old_barn, pumpkin_patch,beside).
  35. door(pumpkin_patch,cornfield,beside).
  36. door(empty_fields,pumpkin_patch,above).
  37. door(church,empty_fields,above).
  38. door(cemetary,church,above).
  39. door(pumpkin_patch, beaten_path,beside).
  40. door(beaten_path,main_road,beside).
  41. hiddendoor(cornfield,haystack,beside).
  42. hiddendoor(nest, beaten_path,above).
  43. hiddendoor(empty_fields,nest,beside).
  44.  
  45.  
  46. %ITEMS
  47.  
  48. item(mailboxkey,'An old rusted out key that likely fits a mailbox', hidden, haystack, moveable).
  49. item('iron altar', 'A solid iron altar', nothidden, church, fixed).
  50. item('skeleton sword', 'A crumbling sword of polished Ivory.', nothidden, cemetary, moveable).
  51. item('giant golden egg', 'a brilliant solid gold egg',nothidden,nest,fixed).
  52. item('giant belt of gender bending', 'a belt with an unknown purpose', hidden, pumpkin_patch,moveable).
  53. item(mailbox, 'A sweet looking mailbox. It appears to be locked.',nothidden,main_road,fixed).
  54. item(mail, 'A piece of mail',nothidden,nowhere,moveable).
  55.  
  56.  
  57. %START BASIC COMMANDS
  58.  
  59. connected(X,Y) :- door(X,Y,Z); door(Y,X,Z).
  60.  
  61. look :- where(X), location(X, Y), nl, write(Y), nl, nl, show_items, nl, adjacent.
  62.  
  63. show_items :- where(Y), item(V,W,nothidden,Y,Z), write('You see an '), write(V), fail.
  64. show_items.
  65.  
  66. itemsearch :- where(Y), item(V,W,hidden,Y,Z), retract(item(V,_,_,_,_)), assert(item(V,W,nothidden,Y,Z)), write('You found a '), write(V).
  67. itemsearch.
  68.  
  69. examine(V) :- where(Y), item(V,W,X,Y,fixed), write(W), nl; item(V,W,X,carrying,Z), reader(V); write('Nothing here.').
  70.  
  71. reader(V) :- item(mail,W,X,Y,Z), write('Welcome to Zork knockoff!').
  72.  
  73. inventory :- item(V,W,X,carrying,Z), write(W), nl, fail.
  74.  
  75. take(V) :- where(Y), item(V,W,X,Y,Z), retract(item(V,_,_,_,_)), assert(item(V,W,X,carrying,Z)), write('You got it!').
  76.  
  77. drop(V) :- where(Y), item(V,W,X,G,Z), retract(item(V,_,_,_,_)), assert(item(V,W,X,Y,Z)).
  78.  
  79. open(X) :- where(Y), item(mailboxkey,_,_,carrying,_), item(X,A,B,Y,C),retract(item(X,_,_,_,_)), assert(item(openmailbox,'A now open mailbox',nothidden,main_road,fixed)), item(mail,W,M,N,Z), retract(item(mail,_,_,_,_)), assert(item(mail,W,M,carrying,Z)), write('You found some mail!').
  80.  
  81. h_adjacent :- write('You can move to'), nl.
  82. adjacent :- h_adjacent, where(X), connected(X,Y), write(Y), nl, fail.
  83. adjacent.
  84.  
  85. move(Y) :- where(X), retract(back(_)), assert(back(X)), connected(X,Y), retract(where(_)), assert(where(Y)), write('You are now in the '), write(Y), nl, look; write('I see no way to get to the '), write(Y), write(' from here.').
  86.  
  87. doorsearch :- where(X), hiddendoor(X,Y,Z), write('Alas! You caught a break. There is a hidden '), write(Y), write(' here! '), assert(door(X,Y,Z)), retract(hiddendoor(X,Y,Z)), write('Search again?'), nl, nl, look; where(X), hiddendoor(Y,X,Z), write('Alas! You caught a break. There is a hidden '), write(Y), write(' here! '), assert(door(Y,X,Z)), retract(hiddendoor(Y,X,Z)), write('Search again?'), nl, nl, look.
  88. doorsearch.
  89.  
  90. search :- doorsearch, itemsearch;  write('These are not the droids you are looking for.').
  91.  
  92. back :- back(X), move(X).
  93.  
  94. teleport(X) :- location(X,Y), retract(where(_)), assert(where(X)), look.
  95.  
  96. help :- write('Commands: look, move, back, search.').
  97. gmhelp :- write('GM Commands: teleport.').
  98.  
  99. boring :- write('Sorry.').
Add Comment
Please, Sign In to add comment