Re: [Tutor] First real script

2006-11-09 Thread Hieu Hoang
Hi Carlos, I hope this module would help you with the binary conversion part: def tobits(inte,size = 3): """Copy an integer's bits from memory""" s='' for i in range(size): s += str((inte & (1<>i) #bits are extracted right-to-left s = s[::-1] #reverse the result string

Re: [Tutor] First real script

2006-11-08 Thread Carlos
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

Re: [Tutor] First real script

2006-11-07 Thread Luke Paireepinart
Carlos wrote: > Hello to all, > > Ok, after reading your comments I ended up with this: > > #Easy_2DCA_01.py > #A very basic 2D script that lets you play with Wolfram's rule 30 > > A_List = [0]*10+[1]+[0]*10 > A_Len = len(A_List) > B_List = [] > print A_List > Iterations = 5 > > rule_30 = { >

Re: [Tutor] First real script

2006-11-07 Thread Alan Gauld
"Carlos" <[EMAIL PROTECTED]> wrote > As you may have noticed the name of the script has changed, I will > now > try a 3D CA. I have been thinking that the best way to do this would > be > to use a matrix, like those found in SciPy. Do you think this is a > good > idea? Using a matrix is fine

Re: [Tutor] First real script

2006-11-07 Thread Carlos
Hello to all, Ok, after reading your comments I ended up with this: #Easy_2DCA_01.py #A very basic 2D script that lets you play with Wolfram's rule 30 A_List = [0]*10+[1]+[0]*10 A_Len = len(A_List) B_List = [] print A_List Iterations = 5 rule_30 = { (1, 1, 1) : 0, (1, 1, 0) : 0,

Re: [Tutor] First real script

2006-11-06 Thread Luke Paireepinart
Danny Yoo wrote: >> Do you know a better way to do this? >> [snip stuff] >> > > Hi Carlos, > > Here's one way to handle it. If you're familiar with modulo "clock" > arithmetic, you might want to apply it above. > Also, consider this example, Carlos: >>> aList = [1,2,3,4,5,6] >>> a,b,c =

Re: [Tutor] First real script

2006-11-06 Thread Alan Gauld
"Danny Yoo" <[EMAIL PROTECTED]> wrote > Here's one way to handle it. If you're familiar with modulo "clock" > arithmetic, you might want to apply it above. Indeed, I should have thought of that. Good catch Danny. Alan G. ___ Tutor maillist - Tut

Re: [Tutor] First real script

2006-11-06 Thread Alan Gauld
"Carlos" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Do you know a better way to do this? > >if i < A_Len-1: >a = A_List[i-1] >b = A_List[i] >c = A_List[i+1] >else: >a = A_List[i-1] >

Re: [Tutor] First real script

2006-11-06 Thread Danny Yoo
> Do you know a better way to do this? > >if i < A_Len-1: > >a = A_List[i-1] >b = A_List[i] >c = A_List[i+1] > >else: > >a = A_List[i-1] >b = A_List[i] >c = A_List[0] Hi Carlos,

Re: [Tutor] First real script

2006-11-06 Thread Carlos
Hi again, Thanks for your comments they are really appreciated. Alan, yes you are right, there is no need to use S, A_Len works the same way. Beginner mistake The dictionary way seems to be way better than my idea, will give it a try. And Danny, your CA is very nice. Do you know a better way

Re: [Tutor] First real script

2006-11-06 Thread Alan Gauld
"Carlos" <[EMAIL PROTECTED]> wrote > Here is the code: > Note: Right now maya is not needed to run the code. > > import time > > #This is the initial state. You can put as many integers as you wish > A_List = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1] > > A_Len = len(A_List) > print 'A_List: ',A_Lis

Re: [Tutor] First real script

2006-11-06 Thread Danny Yoo
On Mon, 6 Nov 2006, Carlos wrote: > This is my first script, I mean the first that I'm trying to do on my > own. Its a very simple Cellular Automata thing, the idea is that the > initial list A_List is rewritten based on some rules, in this case > Wolfram's rule 30. You can modify the list le