CombatRandom.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // using System;
  2. //
  3. //
  4. // namespace CombatLibrary.CombatLibrary.CombatCore.Utility
  5. // {
  6. // public class CombatRandom
  7. // {
  8. // // private const int MBIG = 2147483647;
  9. // // private const int MSEED = 161803398;
  10. // // private const int MZ = 0;
  11. // public int inext;
  12. // public int inextp;
  13. // private int[] SeedArray = new int[56];
  14. //
  15. // public int randCount;
  16. //
  17. // public CombatRandom()
  18. // : this(Environment.TickCount)
  19. // {
  20. // }
  21. //
  22. //
  23. // public CombatRandom(int Seed)
  24. // {
  25. // int num1 = 161803398 - (Seed == int.MinValue ? int.MaxValue : Math.Abs(Seed));
  26. // this.SeedArray[55] = num1;
  27. // int num2 = 1;
  28. // for (int index1 = 1; index1 < 55; ++index1)
  29. // {
  30. // int index2 = 21 * index1 % 55;
  31. // this.SeedArray[index2] = num2;
  32. // num2 = num1 - num2;
  33. // if (num2 < 0)
  34. // num2 += int.MaxValue;
  35. // num1 = this.SeedArray[index2];
  36. // }
  37. //
  38. // for (int index3 = 1; index3 < 5; ++index3)
  39. // {
  40. // for (int index4 = 1; index4 < 56; ++index4)
  41. // {
  42. // this.SeedArray[index4] -= this.SeedArray[1 + (index4 + 30) % 55];
  43. // if (this.SeedArray[index4] < 0)
  44. // this.SeedArray[index4] += int.MaxValue;
  45. // }
  46. // }
  47. //
  48. // this.inext = 0;
  49. // this.inextp = 21;
  50. // Seed = 1;
  51. // }
  52. //
  53. // protected virtual float Sample() => this.InternalSample() * (float)4.6566128752458E-10;
  54. //
  55. // private int InternalSample()
  56. // {
  57. // int inext = this.inext;
  58. // int inextp = this.inextp;
  59. // int index1;
  60. // if ((index1 = inext + 1) >= 56)
  61. // index1 = 1;
  62. // int index2;
  63. // if ((index2 = inextp + 1) >= 56)
  64. // index2 = 1;
  65. // int num = this.SeedArray[index1] - this.SeedArray[index2]+randCount;
  66. // if (num == int.MaxValue)
  67. // --num;
  68. // if (num < 0)
  69. // num += int.MaxValue;
  70. // // this.SeedArray[index1] = num;
  71. // this.inext = index1;
  72. // this.inextp = index2;
  73. // randCount+=1000000;
  74. // if (randCount < 0)
  75. // {
  76. //
  77. // randCount = 0;
  78. // }
  79. //
  80. // return num;
  81. // }
  82. //
  83. //
  84. // public virtual int Next() => this.InternalSample();
  85. //
  86. // private float GetSampleForLargeRange()
  87. // {
  88. // int num = this.InternalSample();
  89. // if (this.InternalSample() % 2 == 0)
  90. // num = -num;
  91. // return (num + (float)2147483646.0) / (float)4294967293.0;
  92. // }
  93. //
  94. //
  95. // public virtual int Next(int minValue, int maxValue)
  96. // {
  97. // if (minValue > maxValue)
  98. // throw new ArgumentOutOfRangeException(("Argument_MinMaxValue"));
  99. // long num = (long) maxValue - (long) minValue;
  100. // return num <= (long) int.MaxValue ? (int) (this.Sample() * num) + minValue : (int) ((long) (this.GetSampleForLargeRange() * num) + (long) minValue);
  101. // }
  102. //
  103. //
  104. // public virtual int Next(int maxValue)
  105. // {
  106. // if (maxValue < 0)
  107. // throw new ArgumentOutOfRangeException("ArgumentOutOfRange_MustBePositive");
  108. // return (int) (this.Sample() *maxValue);
  109. // }
  110. //
  111. //
  112. //
  113. //
  114. // public virtual void NextBytes(byte[] buffer)
  115. // {
  116. // if (buffer == null)
  117. // throw new ArgumentNullException(nameof(buffer));
  118. // for (int index = 0; index < buffer.Length; ++index)
  119. // buffer[index] = (byte) (this.InternalSample() % 256);
  120. // }
  121. // }
  122. // }