Anyone doing the Conway's Game of Life? I've started on that and am understanding what is going on with the code provided (*I think*), but am unsure of how to get the random blocks. I tried a for loop to go through the dictionary of block_list, but nothing happens. Any ideas? Here's what I have: for blocks in range(len(self.block_list)): for squares in range(len(self.canvas)): block = Block(Point(x, y), 'red')
I haven't tried this exercise myself, but think that all your code will only create block objects and then do nothing with them. What you probably want is random numbers picked from each range, up to the number of points you require, with those blocks in an array? Something like: import random randomPoints = 4 blocks = [] for dummy in range(randomPoints): self.block_list[random.randrange(len(self.block_list)] = # whatever a red point is ... or something like that, this would randomly select 4 points, say and set them to red. Hope this helps
which is that from?
unknon wn
Join our real-time social learning platform and learn together with your friends!