[Tutor] A Text Adventure Problem

bob gailer bgailer at gmail.com
Sun Mar 24 21:58:02 CET 2013


On 3/24/2013 3:41 PM, John Bochicchio wrote:
> I've been trying to write a simple test text adventure, but have been 
> running into serious problems. Here is the error I get when I run it. 
> It will give me the opening text and lets me make my first choice.
What did you enter? I will bet is was 'window'.
> Then I get this.
>
> error "Traceback: (Most recent call last)
> file "game1.py", line 104, in <module>
> RUNNER (ROOMS, shack_front)
> file "game1.py", line 100 in runner
> room = map[next]
> keyerror= none
>
[snip]

Questions:
1 - what are you using to run your code?
2 - Version of Python?
3 - Operating system?
4 - Did you think about what the error might mean?

Observations:

1 - The traceback does not match your code, so either you retyped it or 
you are using some unusual way of running the program.

Compare
RUNNER (ROOMS, shack_front)
with
runner (ROOMS, 'shack_front')

2 - the error normally would look like KeyError: None rather than 
keyerror= none

3 - The various room functions have at least one way out of them with no 
return statement. The value returned in that case is None.

4 - There are many many blank lines in the program making it much harder 
to read. In future eliminate most or all of them.

5 - Most of us do not have the patience to count down 100 lines. In 
future flag the line with something like:
         room = map[next] <======== line 100

6 -     quips = ["You've become a zombie and eat you pals. Douche."
              "You've died and left your comrades to fend for 
themselves. Douche"
              "Your whole group dies because of you. Douche."
              "You've got terrible planning skills, and ruined the teams 
chances of survival. Douche."]
quips is a list with one element, consisting of one string or 244 
characters.
print quips[randint(0, len(quips)-1)]
will always print the entire string.
Perhaps you meant to put a comma at the end of each line?

HTH and good luck.

-- 
Bob Gailer
919-636-4239
Chapel Hill NC

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130324/7b39b9e3/attachment-0001.html>


More information about the Tutor mailing list