Hacker News new | past | comments | ask | show | jobs | submit login

this should do the trick...

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



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




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: