[Tutor] First realscript + Game of Life

Luke Paireepinart rabidpoobear at gmail.com
Fri Nov 10 08:07:51 CET 2006


Carlos wrote:
> Hallo to All,
>
> Hey Rooy, so its possible to copy binary numbers from memory? I had 
> the impression that this could be done, but obviously it is too much 
> for me. This way is going to be faster than the hack that I tried 
> before, right? Thanks for the  module : )
What?
I think you're talking to someone else here, cause I have no idea what 
you mean.
Copy binary numbers from memory?
You mean from any arbitrary memory location you want?
That sounds a lot like C++ pointers to me.
>
> Now I'm tring to implement a Conway's Game of Life 
> <http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life> in Maya with 
> CGKit. It was going well until I got this error:
>
> Traceback (most recent call last):
>   File "<string>", line 14, in ?
>   File "test.py", line 31, in ?
>     Neighbor_Value = BOX_State[i-11]+BOX_State[i-10]+BOX_State[i-9]+\
> IndexError: list index out of range
>
> I know what it means, but I just can't figure out why this happens 
> when the loop reaches 89. Can someone please tell me the reason for 
> this? Here is my code so far:
>
> <snippy snip snapper>
>     Neighbor_Value = BOX_State[i-11]+BOX_State[i-10]+BOX_State[i-9]+\
>                                      BOX_State[i-1]+BOX_State[i+1]+\
>                                      
> BOX_State[i+11]+BOX_State[i+10]+BOX_State[i+9]
>
> Just to explain my plan a little bit: I have two lists, BOX_List and 
> BOX_State. BOX_State is my way to sidestep the wrappping problem. I 
> expected an exception with the last number in the list, but not 10 
> numbers before. As I see it, the problem comes when 'i' reaches 
> BOX_State[i-1] Is this correct?
No, this is not correct.
Your Neighbor_Value line, though it occupies 3 lines, is only one 
statement.  Because of this, Python is showing you that you have an 
error in the line where the statement starts.
However, the problem line is last line, where you try to access 
BOX_State[i+11]
obviously... 89+11 = 100, which is longer than the list.
Tada. :)
>
> And again if you see something that should be different please let me 
> know, in this way I can improve a little bit every time.
Sorry, I only had time to look at the part that was causing the error.
>
> Since there has been some talk about the list itself, when some of you 
> reply to my posts sometimes I get a mail straight to my account. This 
> is very useful because it lets me see the reply before it is posted on 
> the list and because in this way is easier to keep track of the info 
> that is useful for me. The question is: is this a personal option from 
> the person who replys? I would like to have all my answers this way, 
> is it possible?
You get a direct mail when people use the 'reply-all' feature.
I use that exclusively.
I figure if enough people are aggravated by it, they'll get the admin to 
add reply-munging so replies
only go straight to the whole list like on Pygame.
Otherwise, I use reply-all so I don't have to type in 'tutor at python.org' 
every time.
The side effect of other people getting the e-mails is generally not too 
annoying,
because the list is smart enough to not send you an extra copy anyway.
So unless you use the Digest method, you shouldn't notice a difference 
at all.
>
> Thanks a lot for your help.
Sure thing.
>
> Happy coding,
You too.
> Carlos
-Luke


More information about the Tutor mailing list