mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
30 lines
794 B
C#
30 lines
794 B
C#
using System.Collections.Generic;
|
|
|
|
namespace ACE.Server.Entity
|
|
{
|
|
public class Probability
|
|
{
|
|
/// <summary>
|
|
/// Returns the probability of none of the events occurring
|
|
/// from a list of chances
|
|
/// </summary>
|
|
public static float GetProbabilityNone(List<float> chances)
|
|
{
|
|
var probability = 1.0f;
|
|
|
|
foreach (var chance in chances)
|
|
probability *= 1.0f - chance;
|
|
|
|
return probability;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the probability of any of the events occurring
|
|
/// from a list of chances
|
|
/// </summary>
|
|
public static float GetProbabilityAny(List<float> chances)
|
|
{
|
|
return 1.0f - GetProbabilityNone(chances);
|
|
}
|
|
}
|
|
}
|