Open julianmunozm45 opened 8 months ago
I won't be that random anymore but more like a weighted function:
import java.util.Random;
public class FunctionCaller {
private double weightA = 1.0;
private double weightB = 1.0;
private Random random = new Random();
public void callFunctions() {
while (true) {
if (random.nextDouble() < weightA / (weightA + weightB)) {
functionA();
weightA -= 0.1;
weightB += 0.1;
} else {
functionB();
weightB -= 0.1;
weightA += 0.1;
}
weightA = Math.max(weightA, 0.1);
weightB = Math.max(weightB, 0.1);
}
}
private void functionA() {
// Implement function A logic here
System.out.println("Function A called");
}
private void functionB() {
// Implement function B logic here
System.out.println("Function B called");
}
public static void main(String[] args) {
FunctionCaller caller = new FunctionCaller();
caller.callFunctions();
}
}
Nowadays, when hitting /cats/pic-or-fact I either get a long series of facts and sometimes I get just multiple pics in a row. Alter the random number distribution for cat facts delay so it gets more exiting. Or either add artificial delay too to cat pics.