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