R programming challenge: Escape the zombie horde

May 20, 2013
By

(This article was first published on Revolutions, and kindly contributed to R-bloggers)

So when the world is taken over by a Zombie horde, you're going to want to figure out a way to get the human population to safety. This R script by econometrician Francis Smart won't help you do that exactly, but given a list of waypoints to navigate through zombie-infested lands to a safe house, it will tell you how many how many members of your human party survive: 

Zombie Horde

While zombie-escaping might not seem to be a terribly useful application of R (until the outbreak comes, anyway), Francis's script comes with detailed comments that make it a useful example of simulation and animations for budding R programmers. (Try switching up the seed used in the set.seed call to get a new horde of zombies to play with, and experiment with new values of the waypoints variable to guide your hapless humans to safety.) It's also a great example of using the animation package to crate animated GIFs with R. 

If you're looking for a programming challenge, an interesting experiment would be to write a function to automatically select waypoints on the route to safety. You could then run the simulation over and over (using a random seed, this time) and count the number of survivors to evaluate its effectiveness. Let us know what you come up with in the comments. 

Econometrics by Simulation: Strategic Zombie Simulation - Animation - Jimmy's Down

To leave a comment for the author, please follow the link and comment on his blog: Revolutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.