Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

susanjrobertson

  • one year ago

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')

  • This Question is Open
  1. fjfish
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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

  2. JonnyTruelove
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    which is that from?

  3. jibril
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    unknon wn

  4. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.