Skip to content

Instantly share code, notes, and snippets.

@spullara spullara/gist:274437
Created Jan 11, 2010

Embed
What would you like to do?
package com.sampullara.survivor;
import java.security.SecureRandom;
import java.util.Random;
public class Simulator {
public static void main(String[] args) {
Random r = new SecureRandom();
double[] correct = new double[] {
.9525,
.7288,
.9316,
.9817,
.9466,
.5567,
.9617,
.8616,
.8333,
.5647,
.9734,
.8266,
.9163,
.6430,
.7719,
.4723
};
byte[] players = new byte[1000000];
for (double c : correct) {
for (int i = 0; i < players.length; i++) {
byte misses = players[i];
if (misses == 3) continue;
if (r.nextDouble() > c) {
players[i]++;
}
}
}
int total = 0;
for (byte misses : players) {
if (misses == 0) total++;
}
System.out.println(((double)total)/1000000d);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.