v3.1.0: added a new type of standard room to replace empty ones

This commit is contained in:
Evan Debenham
2025-04-23 17:15:39 -04:00
parent 1bea9519ac
commit 31741b931e
10 changed files with 377 additions and 22 deletions

View File

@@ -171,19 +171,24 @@ public class Random {
}
//returns an index from chances, the probability of each index is the weight values in changes
//negative values are treated as 0
public static int chances( float[] chances ) {
int length = chances.length;
float sum = 0;
for (int i=0; i < length; i++) {
sum += chances[i];
sum += Math.max(0, chances[i]);
}
if (sum <= 0){
return -1;
}
float value = Float( sum );
sum = 0;
for (int i=0; i < length; i++) {
sum += chances[i];
sum += Math.max(0, chances[i]);
if (value < sum) {
return i;
}