Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Last active December 17, 2015 18:39
Show Gist options
  • Select an option

  • Save practicingruby/5654499 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/5654499 to your computer and use it in GitHub Desktop.
An ecosystem with ten members each of ten unique species(***) play a simple game...
On each round, each creature rolls a 100 sided dice:
- If it rolls a 1, it dies.
- If it rolls a 2, it creates an exact clone of itself which joins
the game on the next round
- Otherwise, nothing happens and the creature simply moves on to the next round
Then all the creatures repeat the process again, and again, and again.
What patterns do you think will emerge in the ecosystem as a whole as
the game goes on?
Think about the problem and answer it based on your intuition first, before
attempting to program it or analyze it formally. Did you guess right?
----------------------------------------------------------------------------
(***) The only distinguishing factor between species is that
they are a member of that species (i.e. the only thing that separates a Foo
creature from a Bar creature is that one is labeled Foo and the other
is labeled Bar).
@petebarton

Copy link
Copy Markdown

I guessed incorrectly. Thanks for the fun exercise.

@chastell

Copy link
Copy Markdown

YOU KNEW WHAT WOULD HAPPEN ALL ALONG, YOU BASTARD! THIS IS SO SAD.

I didn’t guess the speed at which things will happen; I particularly like the version when the ecosystem is ten times as big:

ecosystem = (:a..:j).to_a * 10

while sleep 0.01
  puts ecosystem.sort.join
  ecosystem = ecosystem.flat_map do |member|
    case rand 100
    when 1 then []
    when 2 then [member, member]
    else        [member]
    end
  end
end

@practicingruby

Copy link
Copy Markdown
Author

@chastell: Yeah, I find the results of this riddle unsettling too. :-/

Thanks for sharing your code, it's a neat visualization.

@akmassey

akmassey commented Jun 1, 2013

Copy link
Copy Markdown

@chastell: Thanks for sharing your code. Nice visualization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment