R programming challenge: Escape the zombie horde

[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 their blog: Revolutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)