Hacker News new | ask | show | jobs
by sdenton4 422 days ago
this should do the trick...

  while creatures:
    c = get_random_creature()
    if c.is_dead():
      creatures.pop(c)
    else:
      creatures.add(c.mutate())
1 comments

You also need selection, not just mutation (I know you are being silly, so am I)
Selection is handled by asynchronous events which populate the is_dead() boolean.

Critiquing my own code, though, it should really be a check against 'can_reproduce()' rather than 'is_dead()'.