Hi Again, Luke, I left it this way now:
x = A_List[i-1] y = A_List[i] z = A_List[(i+1) % A_Len] Probably the other way is shorter but right now I feel comfortable as it is now :-[ , Danny had already mentioned this method before, but it didn't sink properly until now. And yes I need it to wrap around because if not the behavior changes, at least it happened in my tests. Now I'm tring to make it possible to choose which rule to use, my first idea was: R_30 = [0,0,0,1,1,1,1,0] R_110 = [0,1,1,0,1,1,1,0] R = R_110 rule = { (1, 1, 1) : R[0], (1, 1, 0) : R[1], (1, 0, 1) : R[2], (1, 0, 0) : R[3], (0, 1, 1) : R[4], (0, 1, 0) : R[5], (0, 0, 1) : R[6], (0, 0, 0) : R[7], } I believe that in this way all possible rules could be defined by a list. The problem is that I'm going to need 256 lists. What would be real nice is to input a number, lets say 30 and have it converted to binary notation so it would look like 1110, then add enough zeros to the left and end up with 0001110, and finally convert this to a list than can be referenced in the dictionary. Here is the code: #This is a hacked version of 'tobinary' from: #http://gnosis.python-hosting.com/voting-project/OVC-Demo2/att-0020/convert.py def tobinary(dec): """Convert a decimal number to binary. Parameters: dec: The decimal number """ bin = [] while dec > 0: bit = int(dec % 2) bin.insert(0, bit) dec = (dec - bit)/2 print bin ## This area formats a Bin number between 0 and 255 ## so it conforms with CA rules formatting b_len = len(bin) print 'b_len: ', b_len while b_len < 8: bin[0:0] = [0] b_len = len(bin) print bin tobinary(30) Is this a good way to proceed? Alan, about going 3D, I agree a normal 2D list will do, but I'm really afraid of the list wrapping, this time squared (or is it cubed?). I'm going to need rules for center, corner and border cells. I'm afraid... Thanks a lot, Carlos _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor