[Tutor] First realscript + Game of Life
Carlos
carloslara at web.de
Fri Nov 10 00:04:41 CET 2006
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 : )
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:
from maya.mel import *
from random import *
BOX_List = []
BOX_State = []
rows = 10
columns = 10
for x in range (rows):
for z in range(columns):
State = randint(0,1)
Name = 'BOX_%i_%i'%(x,z)
BOX_List.append(Name)
BOX_State.append(State)
if State == 1:
polyCube(name = (Name))
move(z,0,x)
for i in range (rows*columns):
Cell_Value = BOX_State[i]
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?
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.
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?
Thanks a lot for your help.
Happy coding,
Carlos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061110/511d41fc/attachment.htm
More information about the Tutor
mailing list