Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby Kaigi 2015: Prepare yourself against Zombie epidemic

Ruby Kaigi 2015: Prepare yourself against Zombie epidemic

The news is everywhere: some weird disease makes the dead walking. We do not know yet if it is highly contagious. What should we do? What we do everyday: writing code.

This couldn't be a better moment to use an agent based model — a technique that simulates interactions between agents in a environment to understand their effects as a whole. For such, we'll visit its minimal Ruby implementation, address some common design, simulate the Zombie epidemic, visualize it, and test different survival strategies to hopefully find the best one.

We can code, we'll be prepared ... or not.

The code: https://github.com/toch/zombie_epidemic

Christophe Philemotte

December 14, 2015
Tweet

More Decks by Christophe Philemotte

Other Decks in Programming

Transcript

  1. stm = StateTransitionMachine.new # create states: # - susceptible #

    - infected # - zombie # - dead # create transitions # set default initial state
  2. steps = 100 agents = create_the_agents steps.times do agents.each do

    |agent| agent.act; agent.age end agents.each { |agent| agent.commit } remove_the_deads(agents) end
  3. steps = 100 agents = create_the_agents steps.times do agents.each do

    |agent| agent.act; agent.age end agents.each { |agent| agent.commit } remove_the_deads(agents) end
  4. steps = 100 agents = create_the_agents steps.times do agents.each do

    |agent| agent.act; agent.age end agents.each { |agent| agent.commit } remove_the_deads(agents) end
  5. steps = 100 agents = create_the_agents steps.times do agents.each do

    |agent| agent.act; agent.age end agents.each { |agent| agent.commit } remove_the_deads(agents) end
  6. steps = 100 agents = create_the_agents steps.times do agents.each do

    |agent| agent.act; agent.age end agents.each { |agent| agent.commit } remove_the_deads(agents) end
  7. steps = 100 agents = create_the_agents steps.times do agents.each do

    |agent| agent.act; agent.age end agents.each { |agent| agent.commit } remove_the_deads(agents) end
  8. steps = 100 agents = create_the_agents steps.times do agents.each do

    |agent| agent.act; agent.age end agents.each { |agent| agent.commit } remove_the_deads(agents) end
  9. steps = 100 agents = create_the_agents steps.times do agents.each do

    |agent| agent.act; agent.age end agents.each { |agent| agent.commit } remove_the_deads(agents) end
  10. steps = 100 agents = create_the_agents steps.times do agents.each do

    |agent| agent.act; agent.age end agents.each { |agent| agent.commit } remove_the_deads(agents) end