The Turncoat
The Turncoat believes that because of the other combatants so far, the majority will alternate after each round between good and evil more often than it stays on the same side. Thus he begins the first round by arbitrarily siding with good, then alternates every round in an attempt to stay on the winning or losing team more often than not.
package Humans;
public class Turncoat extends Human {
public final String takeSides(String history) {
String[] hist = history.split(",");
return (hist.length % 2) == 0 ? "good" : "evil";
}
}
package Humans;
public class Turncoat extends Human {
public final String takeSides(String history) {
String[] hist = history.split(",");
return (hist.length % 2) == 0 ? "good" : "evil";
}
}
After writing this, I realized that due to the entries based on statistical analysis, momentum would cause the majority to switch sides less as more rounds have been completed. Hence, the the Lazy Turncoat.
The Lazy Turncoat
The Lazy Turncoat starts off like the Turncoat, but as rounds pass, he gets lazier and lazier to switch to the other side.
package Humans;
public class LazyTurncoat extends Human {
public final String takeSides(String history) {
int round = history.length() == 0 ? 0 : history.split(",").length;
int momentum = 2 + ((round / 100) * 6);
int choice = round % momentum;
int between = momentum / 2;
return choice < between ? "good" : "evil";
}
}
package Humans;
public class LazyTurncoat extends Human {
public final String takeSides(String history) {
int round = history.length() == 0 ? 0 : history.split(",").length;
int momentum = 2 + ((round / 100) * 6);
int choice = round % momentum;
int between = momentum / 2;
return choice < between ? "good" : "evil";
}
}