Re: [Tutor] results not quite 100 percent yet

2008-02-21 Thread Jeff Younker
Here is a strict translation of your code. The algorithm remains the same, but it has been cleaned up a bit. Duplications have been removed, and the various logical bits have been broken down into separate functions. I suspect you don't know about random.randint(low, high). It generates

Re: [Tutor] results not quite 100 percent yet

2008-02-21 Thread Tyler Smith
On 2008-02-20, bhaaluu <[EMAIL PROTECTED]> wrote: > As far as I can see, these routines give me the results > I'm looking for. I get a distribution of four negative numbers, > four positive integers in the range 10 to 110, and nothing > is placed in room 6 or room 11: > Just for the hell of it, he

Re: [Tutor] results not quite 100 percent yet

2008-02-21 Thread bhaaluu
On Thu, Feb 21, 2008 at 8:49 AM, Tyler Smith <[EMAIL PROTECTED]> wrote: > > Not shorter, but definitely clearer would be to replace your magic > numbers with variables: > > entrance = 6 > exit = 11 > death_room = 13 > > Replacing each occurrence of those numbers in your code with the > varia

Re: [Tutor] results not quite 100 percent yet

2008-02-21 Thread Tyler Smith
On 2008-02-21, bhaaluu <[EMAIL PROTECTED]> wrote: > On Thu, Feb 21, 2008 at 7:32 AM, Kent Johnson <[EMAIL PROTECTED]> wrote: >> >> > Other beginning programers shouldn't have any problems using >> > these routines. >> >> As long as they use the same number of rooms and entrance and exit >> room

Re: [Tutor] results not quite 100 percent yet

2008-02-21 Thread bhaaluu
On Thu, Feb 21, 2008 at 7:32 AM, Kent Johnson <[EMAIL PROTECTED]> wrote: > > > Other beginning programers shouldn't have any problems using > > these routines. > > As long as they use the same number of rooms and entrance and exit > rooms, or they know the places to make the magic edits... > >

Re: [Tutor] results not quite 100 percent yet

2008-02-21 Thread Kent Johnson
bhaaluu wrote: >> Those two block of code above are SO similar that sure they can be combined >> into one, or at least the first parts of them. >> > > Optimization is the LEAST of my worries at this point. The suggested change is not an optimization for speed, it is a reorganization for clarit

Re: [Tutor] results not quite 100 percent yet

2008-02-21 Thread bhaaluu
On Wed, Feb 20, 2008 at 6:39 PM, Tiger12506 <[EMAIL PROTECTED]> wrote: > > I'll throw a couple of thoughts out there since I know that you appreciate > to see many points of view. > > > > #!/usr/bin/python > > Hard-coded. That means you have to change the program to change the game. It > would

Re: [Tutor] results not quite 100 percent yet

2008-02-20 Thread Tiger12506
> As far as I can see, these routines give me the results > I'm looking for. I get a distribution of four negative numbers, > four positive integers in the range 10 to 110, and nothing > is placed in room 6 or room 11: I'll throw a couple of thoughts out there since I know that you appreciate to

Re: [Tutor] results not quite 100 percent yet

2008-02-20 Thread bhaaluu
As far as I can see, these routines give me the results I'm looking for. I get a distribution of four negative numbers, four positive integers in the range 10 to 110, and nothing is placed in room 6 or room 11: #!/usr/bin/python import random #print "\n"*30 table= [[ 0, 2, 0, 0, 0, 0, 0],#

Re: [Tutor] results not quite 100 percent yet

2008-01-31 Thread Alan Gauld
"bhaaluu" <[EMAIL PROTECTED]> wrote > Try it. I'll even send the code that is working in GWBASIC > to you if you think you can get it working in QBasic. Please do, I've not found anything from GWBASIC that didn't work in QBASIC - in fact I use a GWBASIC reference book when writing QBASIC. >

Re: [Tutor] results not quite 100 percent yet

2008-01-31 Thread bhaaluu
On Jan 31, 2008 3:19 AM, Alan Gauld <[EMAIL PROTECTED]> wrote: > "bhaaluu" <[EMAIL PROTECTED]> wrote > > > how to program a TAG in Python. My goal is to code > > the game in POOP > > POOP Python Object Oriented Programming 8^D > > > I fixed enough typos in two of the games in the book > > to

Re: [Tutor] results not quite 100 percent yet

2008-01-31 Thread Alan Gauld
"Luke Paireepinart" <[EMAIL PROTECTED]> wrote >> POOP >> > Python Object-Oriented Programming. Aah! Obvious really. Except - in what way is POOP different to any other kind of OOP? Nobody talks abot JOOP or COOP or SOOP or LOOP or BOOP or... you could go on for hours! Although JOOP used to b

Re: [Tutor] results not quite 100 percent yet

2008-01-31 Thread Alan Gauld
"bhaaluu" <[EMAIL PROTECTED]> wrote > others are mentioned. Hartnell talks about the > pre-computer gamers who recreated historical battles, > who later went on and developed Dungeon & Dragons > type games and RPGs (another genre of gaming that > I know nothing about). Later, those games were >

Re: [Tutor] results not quite 100 percent yet

2008-01-31 Thread Luke Paireepinart
Alan Gauld wrote: > "bhaaluu" <[EMAIL PROTECTED]> wrote > > >> how to program a TAG in Python. My goal is to code >> the game in POOP >> > > POOP > Python Object-Oriented Programming. You really should try to be less funny. I totally didn't read your e-mail seriously cause I was l

Re: [Tutor] results not quite 100 percent yet

2008-01-31 Thread Alan Gauld
"bhaaluu" <[EMAIL PROTECTED]> wrote > how to program a TAG in Python. My goal is to code > the game in POOP POOP > I fixed enough typos in two of the games in the book > to get them running in a GWBASIC interpreter on an > old 286 DOS computer. Why not run it on a modern computer under QB

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 30, 2008 11:25 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > bhaaluu wrote: > > References: > > http://www.csd.uwo.ca/Infocom/ > > http://www.atariarchives.org/adventure/ > > http://en.wikipedia.org/wiki/Tim_Hartnell > > http://www.renpy.org/wiki/renpy/Home_Page > > > > Believe me, I've look

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread Kent Johnson
bhaaluu wrote: > References: > http://www.csd.uwo.ca/Infocom/ > http://www.atariarchives.org/adventure/ > http://en.wikipedia.org/wiki/Tim_Hartnell > http://www.renpy.org/wiki/renpy/Home_Page > > Believe me, I've looked at a LOT of stuff trying to get a > handle on Adventure Games. 8^D I'm surpri

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 30, 2008 10:13 PM, Tiger12506 <[EMAIL PROTECTED]> wrote: > If you're looking for examples - I like the zork games... > > http://www.csd.uwo.ca/Infocom/download.html > I've already looked at the Infocom site and didn't find anything that helped me understand Text Adventure Games like Hartne

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
I got Bob's code running! Here it is for all nineteen rooms: #!/usr/bin/python # 2008-01-30 # bob gailer [Tutor] import random class Room: roomNo = 0 def __init__(self, destinations, updatable=True): Room.roomNo += 1 self.roomNo = Room.roomNo self.destinations = destinations # store

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 30, 2008 2:24 PM, bob gailer <[EMAIL PROTECTED]> wrote: > bhaaluu wrote: > > # N S E W U D T > > travelTable=[[0,2,0,0,0,0,0],# ROOM 1 > > [1,3,3,0,0,0,0],# ROOM 2 > It is good to finally see that you are building an adventure game. > > Consider creating a in

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 30, 2008 12:46 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > bhaaluu wrote: > > > # distribute positive numbers 10 to 109 > > # place in last element of 4 random lists > > # nothing is placed in list 6 or 11 > > cnt=0 > > while cnt <= 3: > > a = range(1,20) > > room = random.choice(a

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bob gailer
bhaaluu wrote: > # N S E W U D T > travelTable=[[0,2,0,0,0,0,0],# ROOM 1 > [1,3,3,0,0,0,0],# ROOM 2 It is good to finally see that you are building an adventure game. Consider creating a instance of a Room class for each room and saving them in a collection such a

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread Kent Johnson
bhaaluu wrote: > # distribute positive numbers 10 to 109 > # place in last element of 4 random lists > # nothing is placed in list 6 or 11 > cnt=0 > while cnt <= 3: > a = range(1,20) > room = random.choice(a) room = random.randint(1, 19) is simpler. > if room != 6 and room != 11 and

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 30, 2008 3:35 AM, Alan Gauld <[EMAIL PROTECTED]> wrote: > In addition to Kents comments about dictionaruy > access I think there may be another problem in > your logic. > > > "bhaaluu" <[EMAIL PROTECTED]> wrote > > > The first loop is supposed to populate G with > > a random range of 4 integ

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 30, 2008 9:22 AM, Kent Johnson <[EMAIL PROTECTED]> wrote: > This is implementation dependent. >[snip] > > > if travelTable.values()[roomNum-1][0] != 0: > > Again, the use of travelTable.values() is pointless, inefficient (it > creates a new list every time you call it) and indetermin

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread Kent Johnson
bhaaluu wrote: > On Jan 30, 2008 8:24 AM, Kent Johnson <[EMAIL PROTECTED]> wrote: >> bhaaluu wrote: >>> Now that you mention it, I do seem to remember that the order of >>> a list is indeterminate. >> No; the order of a dict is indeterminate, and consequently the order of >> lists derived from dict

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 30, 2008 8:24 AM, Kent Johnson <[EMAIL PROTECTED]> wrote: > bhaaluu wrote: > > Now that you mention it, I do seem to remember that the order of > > a list is indeterminate. > > No; the order of a dict is indeterminate, and consequently the order of > lists derived from dicts with keys(), val

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread Kent Johnson
bhaaluu wrote: > Now that you mention it, I do seem to remember that the order of > a list is indeterminate. No; the order of a dict is indeterminate, and consequently the order of lists derived from dicts with keys(), values(), etc. is indeterminate. The order of a list is determined by how you

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 29, 2008 9:26 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > bhaaluu wrote: > > if keY == 6 or keY == 11 or tablE.values()[keY-1][6] != 0: > > tablE.values()[5][6] = 0 > > tablE.values()[10][6] = 0 > > This is not the right way to access the values of a dict. tablE.values(

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bhaaluu
On Jan 29, 2008 9:26 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > Try > if keY == 6 or keY == 11 or tablE[keY-1][6] != 0: > tablE[5][6] = 0 > tablE[10][6] = 0 > > etc. > > Kent > > PS what's with the strange capitalization of variable names? It's a test snippet. I use unusu

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread Alan Gauld
"bhaaluu" <[EMAIL PROTECTED]> wrote In addition to Kents comments about dictionaruy access I think there may be another problem in your logic. > The first loop is supposed to populate G with > a random range of 4 integers 10 to 109 > in random keys 1-19 that have a zero (except keY 6 and keY

Re: [Tutor] results not quite 100 percent yet

2008-01-29 Thread Kent Johnson
bhaaluu wrote: > if keY == 6 or keY == 11 or tablE.values()[keY-1][6] != 0: > tablE.values()[5][6] = 0 > tablE.values()[10][6] = 0 This is not the right way to access the values of a dict. tablE.values() is a list of the values in tablE, but it is not in the order you expect;

[Tutor] results not quite 100 percent yet

2008-01-29 Thread bhaaluu
Greetings, I'm having a problem with the following test. I make a dictionary with 19 keys (1 to 19). Each key has a list of 7 numbers (A to G) # Set up the table #key# A B C D E F G tablE= {1:[ 0, 2, 0, 0, 0, 0, 0],# 1 2:[ 1, 3, 3, 0, 0, 0, 0],# 2 3:[ 2, 0, 5,