Skip to content

Instantly share code, notes, and snippets.

@ashaw
Last active December 16, 2015 13:08
Show Gist options
  • Save ashaw/5439381 to your computer and use it in GitHub Desktop.
Save ashaw/5439381 to your computer and use it in GitHub Desktop.
How we're calculating death in our HeartSaver experimental news game.
var calculateDeath = function(hospital, pickupTime, travelTime) {
var survivalChance = 1;
// A victim’s chance of survival decreases by 7 to 10 percent / minute
// that passes without defibrillation.
// http://www.heart.org/idc/groups/heart-public/@wcm/@ecc/documents/downloadable/ucm_438703.pdf
survivalChance -= (0.10 * pickupTime);
// Time in transit to ER (.58% / minute, via the Google Directions API)
// http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2464671/table/tbl1/
survivalChance -= (0.0058 * travelTime);
// Medicare heart attack mortality
// http://www.medicare.gov/HospitalCompare/Data/RCD/30-day-measures.aspx
survivalChance *= (1 - (hospital.heart_attack_mortality_rate / 100));
return (Math.random() < survivalChance);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment