[Tutor] my newbie program
Gregor Lingl
glingl@aon.at
Tue Nov 19 05:33:01 2002
alan.gauld@bt.com schrieb:
>>> self.commandlist = ['look','n']
>>>
>>>
>>>
>>I think this won't work. there is no name self here. So better
>>either delete the self. to create a class-variable
>>
>>
>
>Oops. Yes that's what I intended!
>
>
>
>>> while 1:
>>> me.act()
>>> if not map(lambda x: x != 0, me.location.exits):
>>> break
>>>
>>>
>>>
>>>
>>This is a little bit disturbing. Wasn't the original concept,
>>that exits should be a four element list, containing exits
>>
>>
>
>Dunno, I assumed it was just a list of exits with no numerical
>restriction. I guess 4 makes sense tho'. Shouldn't change the
>above tho' it still checks for a list of all zeros...
>
>
I don't think, that this does, what you expect:
>>> map(lambda x: x!=0, [0,0,0,0])
[0, 0, 0, 0]
>>> not map(lambda x: x!=0, [0,0,0,0])
0 # no break
..... but:
>>> not map(lambda x: x!=0, [])
1 # break
Regards, Gregor
>The real point was to do more than just call act() once!
>
>Alan G.
>
>
>
>