cn.nukkit.entity.ai.evaluator.ProbabilityEvaluator Maven / Gradle / Ivy
package cn.nukkit.entity.ai.evaluator;
import cn.nukkit.api.PowerNukkitXOnly;
import cn.nukkit.api.Since;
import cn.nukkit.entity.EntityIntelligent;
import java.util.concurrent.ThreadLocalRandom;
@PowerNukkitXOnly
@Since("1.6.0.0-PNX")
public class ProbabilityEvaluator implements IBehaviorEvaluator {
protected int probability;
protected int total;
public ProbabilityEvaluator(int probability, int total) {
this.probability = probability;
this.total = total;
}
@Override
public boolean evaluate(EntityIntelligent entity) {
return ThreadLocalRandom.current().nextInt(total) < probability;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy