using System;
///
/// Random 算法相关方法
///
public partial class Utils
{
///
/// 随机种子
///
private static Random rnd = new Random(Guid.NewGuid().GetHashCode());
///
/// 普通随机方法
///
///
///
///
public static int random(int min, int max)
{
return rnd.Next(min, max);
}
///
/// 在1到1万之间取一个随机值
///
///
public static int random10K()
{
return random(1, 10000);
}
///
/// 直接计算百分比是否落在区间内,相当于骰一次100面骰子,且结果正好小于参数指定的值.
///
/// 百分之x(精度±0.01%)
/// true 本地投筛子成功, false 失败
public static bool randomPercent(int percent)
{
return (random(1, 10000) / 100) <= percent;
}
}