This function will return true X percent of the time, could be useful for games involving probability.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
using System; using System.Collections.Generic; using System.Text; namespace XeonProductions { static class ProbabilityUtils { private static Random random = new Random((int)System.DateTime.Now.Ticks); public static bool GetResult(double percent) { return random.NextDouble() * 100 <= percent; } } } |