Hi, I want to crunch some numbers with Java and I’m going to be testing Crit Chance (a %chance on hit that you’ll deal x times more damage).
Does the code below correctly simulate someone attacking 1 million times with 100 damage and a 10% chance to crit for 300% damage?
//this is a method's body
Random dice = new Random();
double total = 0;
double damage = 100;
for(double i = 1; i < 1000000; i++){
if(dice.nextInt(100) + 1 < 10){
total += damage * 3;
}else{
total += damage;
}
}
return total;