david wrote:
> thanks. i had actually coded this almost exactly the same. i'll try
> to make my questions more specific. i am able to pickle and restore
> world. which is a dictionary of coordinates : room objects. when i
> look at the savefile that pickle generates i can see all my
> descriptions
i have finally got save and restoring to work. here
is my code for posterity. :)
i was (i think) putting the player in a room that
wasnt the room from the pickle.
but somehow the same room.
anyway comments welcome.
import sysimport stringimport
pickleimport os.path
world = {}rooms = []cl
thanks that was very helpful. i added all that stuff because i was
trying to figure out some way of getting at the descriptions and exits.
that is the part i'm stuck on. but knowing that world is all i need is
good because i can focus my efforts better. thanks.
> You could make your save() metho
On 05/12/05, david <[EMAIL PROTECTED]> wrote:
> when i restore from the pickle i can see my exits and descriptions are still
> there.
> def save(self):
> f = open('savefile', 'w')
> pickle.dump(world,f)
> pickle.dump(rooms,f)
> for i in rooms:
> pickl
when i restore from the pickle i can see my exits
and descriptions are still there.
but look won't see the description and move can't
move to the next room.
i am stumped. what is going on here? how can i fix
it? please help?
IDLE 1.1.2 No
Subprocess >>> >rooms[<__main__.R
On Sun, 4 Dec 2005, david wrote:
> i fixed this myself ! i think i can get everything working now so
> please disregard previous messages. if you haven't already. :)
That's great!
By the way, you asked a while back if trying to write a text-adventure
game was a good way to learn how to progra
i fixed this myself !
i think i can get everything working now so please
disregard previous messages.
if you haven't already. :)
- Original Message -
From:
david
To: tutor@python.org
Sent: Sunday, December 04, 2005 10:06
AM
Subject: [Tutor] (no subject)
i adde
programs state (is that correct usage?)
could be important in many different
programs.
- Original Message -
From:
Dan Lowe
To: david
Cc: tutor@python.org
Sent: Sunday, December 04, 2005 1:24
AM
Subject: Re: [Tutor] my text
adventure
On Dec 3, 2005,
On Dec 3, 2005, at 9:40 PM, david wrote: sorry i forgot a subject line. i have looked at the pickle module and was able to pickle world. but i can't figure how to restore everything.import pickledef save_game(state, filename): file = open(filename, 'w') pickle.dump(state, file) file.cl
sorry i forgot a subject line. i have looked at the
pickle module and was able to pickle world.
but i can't figure how to restore everything.
- Original Message -
From:
david
To: tutor@python.org
Sent: Saturday, December 03, 2005 8:36
PM
Subject: [Tutor] (no subje
well i have got some things to work, thanks for the
help.
at this point i am just making things worse so
thats it for tonight.
any comments, suggestions, bug fixes, improvements,
or ideas
on how my program can add to the quality of all our
lives are,
as always, most greatly appreciated.
> i am attempting to write a dig function that will create rooms.
> i have succeeded only in getting a headache :)
> any suggestions on where i am going wrong would
> be super helpful.
Hi David,
You may want to write a unit test to make sure that all the methods of
your class are doing the righ
i am attempting to write a dig function that will create rooms.
i have succeeded only in getting a headache :)
any suggestions on where i am going wrong would
be super helpful.
thanks,
david
world = {}class Room: def
__init__(self,name,coords):
self.contents = [] self.name =
david wrote:
> i just now learned what setter and getter is.
> i did this to make my inventory function work properly.
> i'll try to remove my getter.
The inventory list can be just
for a in self.inventory:
print a.name
You can access object attributes from outside the
> You might want to make coords an init parameter for Room, rather than
> assigning it separately. You could also have Rooms register themselves
> with world as part of their initialization, that would be better than
> having to repeat yourself in the definition of world.
brilliant! i'll do th
david wrote:
> hello again python tutors! my latest attempt to learn python.
> any comments or suggestions most greatly appreciated.
>
> import sys
> import string
> ncoords = [0,0]
> class Room:
> def __init__(self,name):
> self.exits = {}
> self.contents = []
> self.
On Tue, 29 Nov 2005 07:40:18 -0600
"david" <[EMAIL PROTECTED]> wrote:
>hello again python tutors! my latest attempt to learn python.
>any comments or suggestions most greatly appreciated.
I like it! add in some scenery, and you have a game there!
I like the inventory, that is nice to have, but I
hello again python tutors! my latest attempt to
learn python.
any comments or suggestions most greatly
appreciated.
import sysimport stringncoords =
[0,0]class Room: def
__init__(self,name): self.exits =
{} self.contents =
[] self.name =
name self.coords
18 matches
Mail list logo