README.txt 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. This is a faithful port of the “Adventure” game to Python 3 from the
  2. original 1977 FORTRAN code by Crowther and Woods (it is driven by the
  3. same ``advent.dat`` file!) that lets you explore Colossal Cave, where
  4. others have found fortunes in treasure and gold, though it is rumored
  5. that some who enter are never seen again. To encourage the use of
  6. Python 3, the game is designed to be played right at the Python prompt.
  7. Single-word commands can be typed by themselves, but two-word commands
  8. should be written as a function call (since a two-word command would not
  9. be valid Python)::
  10. >>> import adventure
  11. >>> adventure.play()
  12. WELCOME TO ADVENTURE!! WOULD YOU LIKE INSTRUCTIONS?
  13. >>> no
  14. YOU ARE STANDING AT THE END OF A ROAD BEFORE A SMALL BRICK BUILDING.
  15. AROUND YOU IS A FOREST. A SMALL STREAM FLOWS OUT OF THE BUILDING AND
  16. DOWN A GULLY.
  17. >>> east
  18. YOU ARE INSIDE A BUILDING, A WELL HOUSE FOR A LARGE SPRING.
  19. THERE ARE SOME KEYS ON THE GROUND HERE.
  20. THERE IS A SHINY BRASS LAMP NEARBY.
  21. THERE IS FOOD HERE.
  22. THERE IS A BOTTLE OF WATER HERE.
  23. >>> get(lamp)
  24. OK
  25. >>> leave
  26. YOU'RE AT END OF ROAD AGAIN.
  27. >>> south
  28. YOU ARE IN A VALLEY IN THE FOREST BESIDE A STREAM TUMBLING ALONG A
  29. ROCKY BED.
  30. The original Adventure paid attention to only the first five letters of
  31. each command, so a long command like ``inventory`` could simply be typed
  32. as ``inven``. This package defines a symbol for both versions of every
  33. long word, so you can type the long or short version as you please.
  34. You can save your game at any time by calling the ``save()`` command
  35. with a filename, and then can resume it later::
  36. >>> save('advent.save')
  37. GAME SAVED
  38. >>> adventure.resume('advent.save')
  39. GAME RESTORED
  40. >>> look
  41. SORRY, BUT I AM NOT ALLOWED TO GIVE MORE DETAIL. I WILL REPEAT THE
  42. LONG DESCRIPTION OF YOUR LOCATION.
  43. YOU ARE IN A VALLEY IN THE FOREST BESIDE A STREAM TUMBLING ALONG A
  44. ROCKY BED.
  45. You can find two complete, working walkthroughs of the game in its
  46. ``tests`` directory, which you can run using the ``discover`` module that
  47. comes built-in with Python 3::
  48. $ python3 -m unittest discover adventure
  49. I wrote most of this package over Christmas vacation 2010, to learn more
  50. about the workings of the game that so enthralled me as a child; the
  51. project also gave me practice writing Python 3. I still forget the
  52. parentheses when writing ``print()`` if I am not paying attention.
  53. Traditional Mode
  54. ================
  55. You can also use this package to play Adventure at a traditional prompt
  56. that does not require its input to be valid Python. Use your operating
  57. system command line to run the package::
  58. $ python3 -m adventure
  59. WELCOME TO ADVENTURE!! WOULD YOU LIKE INSTRUCTIONS?
  60. >
  61. At the prompt that will appear, two-word commands can simply be
  62. separated by a space::
  63. > get lamp
  64. OK
  65. For extra authenticity, the output of the Adventure game in this mode is
  66. typed to your screen at 1200 baud. You will note that although this
  67. prints the text faster than you can read it anyway, your experience of
  68. the game will improve considerably, especially when a move results in a
  69. surprise.
  70. Why is the game better at 1200 baud? When a paragraph of text is
  71. allowed to appear on the screen all at once, your eyes scan the entire
  72. paragraph for important information, often ruining any surprises before
  73. you can then settle down and read it from the beginning. But at 1200
  74. baud, you wind up reading the text in order as it appears, which unfolds
  75. the narrative sequentially as the author of Adventure intended.
  76. If you created a file with the in-game ``save`` command, you can restore
  77. it later by naming it on the command line::
  78. > save mygame
  79. GAME SAVED
  80. > quit
  81. DO YOU REALLY WANT TO QUIT NOW?
  82. > y
  83. OK
  84. $ python3 -m adventure mygame
  85. GAME RESTORED
  86. >
  87. Notes
  88. =====
  89. * Several Adventure commands conflict with standard Python built-in
  90. functions. If you want to run the normal Python function ``exit()``,
  91. ``open()``, ``quit()``, or ``help()``, then import the ``builtin``
  92. module and run the copy of the function stored there.
  93. * The word “break” is a Python keyword, so there was no possibility of
  94. using it in the game. Instead, use one of the two synonyms defined by
  95. the PDP version of Adventure: “shatter” or “smash.”
  96. Copyright
  97. =========
  98. The ``advent.dat`` game data file distributed with this Python package,
  99. like the rest of the original source code for Adventure, is a public
  100. domain work. Phrases from the original work that have been copied into
  101. my source code from the FORTRAN source (the famous phrase “You have
  102. gotten yourself killed” and so forth) remain public domain and can be
  103. used without attribution.
  104. My own Python code that re-implements the game engine is:
  105. Copyright 2010–2015 Brandon Rhodes
  106. Licensed under the Apache License, Version 2.0 (the "License");
  107. you may not use this file except in compliance with the License.
  108. You may obtain a copy of the License at
  109. http://www.apache.org/licenses/LICENSE-2.0
  110. Unless required by applicable law or agreed to in writing, software
  111. distributed under the License is distributed on an "AS IS" BASIS,
  112. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  113. See the License for the specific language governing permissions and
  114. limitations under the License.
  115. Changelog
  116. =========
  117. | 1.4 — 2016 January 31 — readline editing; added license; bug fix; test fix.
  118. | 1.3 — 2012 April 27 — installs on Windows; fixed undefined commands
  119. | 1.2 — 2012 April 5 — restoring saves from command line; 5-letter commands
  120. | 1.1 — 2011 March 12 — traditional mode; more flexible Python syntax
  121. | 1.0 — 2011 February 15 — 100% test coverage, feature-complete
  122. | 0.3 — 2011 January 31 — first public release