Advertisement
namofure

トバリスロット乱数調整

Nov 19th, 2024 (edited)
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3.  
  4. class LCG
  5. {
  6. static void Main()
  7. {
  8. Console.Write("Enter Initial SEED : 0x"); // 初期SEED入力
  9. if (uint.TryParse(Console.ReadLine(), System.Globalization.NumberStyles.HexNumber, null, out uint Seed))
  10. {
  11. Console.Write("Enter SEED Count :");
  12. if (int.TryParse(Console.ReadLine(), out int count) && count > 0)
  13. {
  14. Console.Write("Enter File Name :");
  15. string outputPath = Console.ReadLine();
  16. using (StreamWriter writer = new(outputPath))
  17. {
  18. for (int i = 0; i < count; i++, Seed = NextSeed(Seed))
  19. {
  20. uint lsr = Seed >> 16;
  21. uint mod = lsr % 100;
  22. int n = 0;
  23.  
  24. //Console.WriteLine($"Iteration {i}: Seed = 0x{Seed:X8}, mod = {mod}");
  25.  
  26. if (mod <= 34)
  27. {
  28. uint ASeed = Seed;
  29. uint Amod;
  30.  
  31.  
  32. do
  33. {
  34. ASeed = NextSeed(ASeed);
  35.  
  36. uint Alsr = ASeed >> 16;
  37. Amod = Alsr % 100;
  38.  
  39. // Console.WriteLine($"Loop {n}: ASeed = 0x{ASeed:X8}, Amod = {Amod}");
  40.  
  41. if (63 <= Amod && Amod <= 99)
  42. {
  43. n++;
  44.  
  45. ASeed = NextSeed(ASeed);
  46. uint BSeed = NextSeed(ASeed);
  47.  
  48. lsr = BSeed >> 16;
  49. mod = lsr % 100;
  50.  
  51. if (mod <= 34)
  52. {
  53. ASeed = BSeed;
  54. }
  55. }
  56. else
  57. {
  58. break;
  59. }
  60. } while (mod <= 34);
  61. }
  62.  
  63. if ( n >= 10)
  64. {
  65. Console.WriteLine($"0x{Seed:X8} {n} times");
  66. writer.WriteLine($"0x{Seed:X8} {n} times");
  67. }
  68. }
  69. Console.WriteLine($"Final Seed 0x{Seed:X8}");
  70. writer.WriteLine($"Final Seed 0x{Seed:X8}");
  71. Console.WriteLine($"Generated {count} seeds. Output saved to {outputPath}");
  72. }
  73. }
  74. else
  75. {
  76. Console.WriteLine("Invalid Input for SEED Count.");
  77. }
  78. }
  79. else
  80. {
  81. Console.WriteLine("Invalid Input for Initial SEED.");
  82. }
  83. }
  84.  
  85. static uint NextSeed(uint Seed)
  86. {
  87. ulong a = 1103515245;
  88. ulong b = 24691;
  89. ulong result = (a * Seed + b) & 0xFFFFFFFF;
  90. return (uint)result;
  91. }
  92. }
  93.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement