Created
July 1, 2017 20:28
-
-
Save vingkan/27e8bf2c319c839d09fa418d22ec5b3c to your computer and use it in GitHub Desktop.
Quarantine control measure recommended by Team Alpha for Lake Spore outbreak in Lake Town.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* RESULTS WITHOUT CONTROL MEASURE | |
* 311 people were infected. | |
* Quarantined 0 people at cost of $0.00 | |
* Outbreak Length: 51.416666666666664 days. | |
* RESULTS WITH CONTROL MEASURE | |
* 81 people were infected. | |
* Quarantined 314 people at cost of $381,390.00 | |
* Outbreak Length: 27.458333333333332 days. | |
*/ | |
public static class QuarantineMeasure extends ControlMeasure { | |
private boolean isQuarantined = false; | |
private int timeQuarantined = 0; | |
private int quarantineFor = (24 * 20); | |
private Location site = null; | |
private List<String> targetLocations; | |
QuarantineMeasure(Person person){ | |
super("Quarantine"); | |
this.setStartDay(17); | |
this.setEndDay(37); | |
this.targetLocations = new ArrayList<String>(); | |
this.targetLocations.add("Restaurant 1 (R)"); | |
this.targetLocations.add("Restaurant 7 (R)"); | |
this.targetLocations.add("Restaurant 16 (R)"); | |
this.site = person.getNamedLocation("Home"); | |
} | |
public Location applyMeasure(City city, Person person, Location nextLoc){ | |
Location res = nextLoc; | |
if(isQuarantined){ | |
if(site != null){ | |
res = site; | |
} | |
if(timeQuarantined > quarantineFor){ | |
res = nextLoc; | |
} | |
timeQuarantined++; | |
} | |
else if(person.getState() == Person.State.SUSCEPTIBLE){ | |
for(String locName : targetLocations){ | |
if(nextLoc.getName().equals(locName)){ | |
isQuarantined = true; | |
break; | |
} | |
} | |
if(!isQuarantined){ | |
for(String locName : targetLocations){ | |
for(Person.Record rec : person.getHistory()){ | |
if(rec.getLocation().getName().equals(locName)){ | |
isQuarantined = true; | |
break; | |
} | |
} | |
if(isQuarantined){ | |
break; | |
} | |
} | |
} | |
} | |
return res; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment