Advertisement
Guest User

Untitled

a guest
Sep 11th, 2023
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.34 KB | None | 0 0
  1. // Pokemon Stadium 2 Mystery Gift Decoration Calculator
  2. // By RainingChain
  3. #include <iostream>
  4. #include <array>
  5. #include <limits>
  6. #include <iomanip>
  7. #include <vector>
  8. #include <unordered_set>
  9. #include <numeric>
  10.  
  11. unsigned char TID_HIGH = 0;
  12. unsigned char TID_LOW = 0;
  13. unsigned char ROUND_TWO_UNLOCKED = 1;
  14.  
  15. using MyInt = unsigned int;
  16.  
  17. MyInt gLCRNGState;
  18.  
  19. void seedLCRNG(MyInt seed) {
  20. gLCRNGState = seed;
  21. }
  22.  
  23. int randLCRNG(void)
  24. {
  25. gLCRNGState = (gLCRNGState * 0x19660D) + 0x3C6EF35F;
  26. return gLCRNGState;
  27. }
  28.  
  29. char selectMysteryGiftItem(unsigned char trainerIdHigh, unsigned char trainerIdLow) {
  30. int rand;
  31. char temp;
  32. unsigned char resultIndex;
  33.  
  34. if ((randLCRNG() & 0xFF) < 25u) {
  35. if ((randLCRNG() & 0xFF) < 50u) {
  36. if ((randLCRNG() & 0xFF) < 50u) {
  37. if ((trainerIdHigh & (1 << 7))) {
  38. resultIndex = 33;
  39. }
  40. else {
  41. resultIndex = 32;
  42. }
  43. }
  44. else {
  45. resultIndex = ((unsigned char)(trainerIdHigh >> 4)) & 7;
  46. resultIndex = (resultIndex + 0x18ull) & 0xFF;
  47. }
  48. }
  49. else {
  50. rand = randLCRNG() & 3;
  51. temp = (trainerIdHigh & (1 << (rand & 0xFF))) ? 1 : 0;
  52. temp = (rand << 1) + temp;
  53. resultIndex = temp;
  54. resultIndex += 0x10ull;
  55. }
  56. }
  57. else {
  58. rand = randLCRNG() & 7;
  59. temp = (trainerIdLow & (1 << (rand & 0xFF))) ? 1 : 0;
  60. resultIndex = ((rand << 1) + temp) & 0xFF;
  61. }
  62. return resultIndex;
  63. }
  64.  
  65. char selectMysteryGiftDecoration(unsigned char trainerIdLow, unsigned char trainerIdHigh, unsigned char roundTwoUnlocked) {
  66. int rand;
  67. char temp;
  68. unsigned char resultIndex;
  69.  
  70. if ((randLCRNG() & 0xFF) < 36u) {
  71. if ((randLCRNG() & 0xFF) < 72u) {
  72. if ((randLCRNG() & 0xFF) < 72u) {
  73. rand = randLCRNG() & 0xFF;
  74.  
  75. if (rand < 77) {
  76. resultIndex = roundTwoUnlocked != 0 ? 34 : 36;
  77. }
  78. else if (rand < 154) {
  79. resultIndex = 36;
  80. }
  81. else if (trainerIdLow & (1 << 7)) {
  82. resultIndex = 33;
  83. }
  84. else {
  85. resultIndex = 32;
  86. }
  87. }
  88. else {
  89. resultIndex = ((unsigned char)(trainerIdLow >> 4)) & 7;
  90. resultIndex = resultIndex + 24ull;
  91. }
  92. }
  93. else {
  94. rand = randLCRNG() & 3;
  95. temp = (trainerIdLow & (1 << (rand & 0xFF))) ? 1 : 0;
  96. temp = (rand << 1) + temp;
  97. resultIndex = temp;
  98. resultIndex += 0x10ull;
  99. }
  100. }
  101. else {
  102. rand = randLCRNG() & 7;
  103. temp = (trainerIdHigh & (1 << (rand & 0xFF))) ? 1 : 0;
  104. resultIndex = ((rand << 1) + temp) & 0xFF;
  105. }
  106. return resultIndex;
  107. }
  108.  
  109. std::pair<char, char> getDecoIdx(MyInt osGetCount)
  110. {
  111. seedLCRNG(osGetCount);
  112.  
  113. randLCRNG(); //selectMysteryGiftResult
  114.  
  115. auto a = selectMysteryGiftItem(TID_LOW, TID_HIGH);
  116. auto b = selectMysteryGiftDecoration(TID_LOW, TID_HIGH, ROUND_TWO_UNLOCKED);
  117. return { a,b };
  118. }
  119.  
  120. int main()
  121. {
  122. std::array<std::vector<unsigned char>, 38> FreqItem = {};
  123. std::array<std::vector<unsigned char>, 38> FreqDeco = {};
  124.  
  125. MyInt osGetCount = std::numeric_limits<MyInt>::min();
  126. MyInt Max = 255; // std::numeric_limits<MyInt>::max();
  127.  
  128. while (true)
  129. {
  130. auto pair = getDecoIdx(osGetCount);
  131. FreqItem[pair.first].push_back(osGetCount);
  132. FreqDeco[pair.second].push_back(osGetCount);
  133.  
  134. if (osGetCount == Max)
  135. break;
  136.  
  137. osGetCount++;
  138. }
  139.  
  140. auto Count = [](const auto& Arr, int start, int end)
  141. {
  142. int c = 0;
  143. for (; start < end; start++)
  144. c += Arr[start].size();
  145. return c;
  146. };
  147.  
  148. std::cout << "Frequency items:\n";
  149. std::cout << " Common:" << Count(FreqItem, 0, 16) << "\n";
  150. std::cout << " Uncommon:" << Count(FreqItem, 16, 24) << "\n";
  151. std::cout << " Rare:" << Count(FreqItem, 24, 32) << "\n";
  152. std::cout << " Ver Rare:" << Count(FreqItem, 32, 38) << "\n";
  153.  
  154. for (size_t idx = 0; idx < FreqItem.size(); idx++)
  155. {
  156. std::cout << "id " << idx << " : " << FreqItem[idx].size() << "|";
  157. for (auto seed : FreqItem[idx])
  158. std::cout << (int)seed << ",";
  159. std::cout << "\n";
  160. }
  161. std::cout << "\n";
  162. std::cout << "Frequency decos:\n";
  163. std::cout << " Common:" << Count(FreqDeco, 0, 16) << "\n";
  164. std::cout << " Uncommon:" << Count(FreqDeco, 16, 24) << "\n";
  165. std::cout << " Rare:" << Count(FreqDeco, 24, 32) << "\n";
  166. std::cout << " Ver Rare:" << Count(FreqDeco, 32, 38) << "\n";
  167. for (size_t idx = 0; idx < FreqDeco.size(); idx++)
  168. {
  169. std::cout << "id " << idx << " : " << FreqDeco[idx].size() << "|";
  170. for (auto seed : FreqDeco[idx])
  171. std::cout << (int)seed << ",";
  172. std::cout << "\n";
  173. }
  174.  
  175. return 0;
  176. }
  177.  
  178.  
  179.  
  180. unsigned char gLCRNGState2;
  181. unsigned char randLCRNG2()
  182. {
  183. gLCRNGState2 = (gLCRNGState2 * 0x0D) + 0x5F;
  184. return gLCRNGState2;
  185. }
  186.  
  187. int main2()
  188. {
  189. for (int i = 0; i < 256; i++)
  190. {
  191. gLCRNGState2 = (unsigned char)i;
  192.  
  193. std::vector<unsigned char> Vec;
  194.  
  195. Vec.push_back(gLCRNGState2);
  196.  
  197. size_t alreadyExistIdx = -1;
  198. while (true)
  199. {
  200. auto NewVal = randLCRNG2();
  201.  
  202. for (size_t j = 0; j < Vec.size(); j++)
  203. {
  204. if (Vec[j] == NewVal)
  205. alreadyExistIdx = j;
  206. }
  207. Vec.push_back(NewVal);
  208.  
  209. if (alreadyExistIdx != -1)
  210. break;
  211. }
  212. std::cout << "Initial seed = " << static_cast<int>(i) << " : ";
  213.  
  214. for (size_t j = 0; j < Vec.size(); j++)
  215. {
  216. if (j == alreadyExistIdx)
  217. std::cout << "|Cycle|";
  218.  
  219. std::cout << static_cast<int>(Vec[j]) << ",";
  220. }
  221.  
  222. std::cout << "\n";
  223. }
  224. return 0;
  225. }
  226.  
  227.  
  228. /*
  229. TID= 0;
  230.  
  231. Frequency items:
  232. Common:231
  233. Uncommon:21
  234. Rare:3
  235. Ver Rare:1
  236. id 0 : 29|3,11,19,35,43,51,59,67,75,83,91,99,107,115,123,131,139,147,155,163,179,187,195,203,211,219,235,243,251,
  237. id 1 : 0|
  238. id 2 : 29|0,8,16,32,40,48,56,64,72,88,96,104,112,120,128,136,144,152,160,168,176,184,192,200,208,216,232,240,248,
  239. id 3 : 0|
  240. id 4 : 29|5,13,29,37,45,53,61,69,85,93,101,109,117,125,133,141,149,157,165,173,181,189,197,205,213,229,237,245,253,
  241. id 5 : 0|
  242. id 6 : 29|2,10,26,34,42,50,58,66,82,90,98,106,114,122,138,146,154,162,170,178,186,194,202,210,218,226,234,242,250,
  243. id 7 : 0|
  244. id 8 : 29|7,15,23,31,39,47,55,63,79,87,95,103,111,119,135,143,151,159,167,175,191,199,207,215,223,231,239,247,255,
  245. id 9 : 0|
  246. id 10 : 29|4,12,20,28,36,44,52,60,76,84,92,100,108,116,132,140,148,156,164,172,188,196,204,212,220,228,236,244,252,
  247. id 11 : 0|
  248. id 12 : 29|1,9,17,25,33,41,49,57,65,73,81,89,97,105,113,129,137,145,153,161,169,185,193,201,209,217,225,241,249,
  249. id 13 : 0|
  250. id 14 : 28|6,14,22,38,46,54,62,70,78,86,94,102,110,126,134,142,150,158,166,182,190,198,206,214,222,238,246,254,
  251. id 15 : 0|
  252. id 16 : 5|24,68,80,180,224,
  253. id 17 : 0|
  254. id 18 : 5|77,121,177,221,233,
  255. id 19 : 0|
  256. id 20 : 6|18,30,74,118,130,230,
  257. id 21 : 0|
  258. id 22 : 5|27,71,127,171,183,
  259. id 23 : 0|
  260. id 24 : 3|124,174,227,
  261. id 25 : 0|
  262. id 26 : 0|
  263. id 27 : 0|
  264. id 28 : 0|
  265. id 29 : 0|
  266. id 30 : 0|
  267. id 31 : 0|
  268. id 32 : 1|21,
  269. id 33 : 0|
  270. id 34 : 0|
  271. id 35 : 0|
  272. id 36 : 0|
  273. id 37 : 0|
  274.  
  275. Frequency decos:
  276. Common:223
  277. Uncommon:25
  278. Rare:7
  279. Ver Rare:1
  280. id 0 : 28|1,9,17,18,25,33,41,49,57,73,74,89,97,105,113,129,130,137,145,153,161,169,185,193,209,225,241,249,
  281. id 1 : 0|
  282. id 2 : 26|6,22,27,38,46,54,62,70,78,86,94,102,110,126,142,150,158,166,182,190,198,206,214,222,227,246,
  283. id 3 : 0|
  284. id 4 : 28|3,11,19,43,59,67,68,75,83,91,99,107,115,123,131,139,147,155,163,179,180,195,203,211,219,235,243,251,
  285. id 5 : 0|
  286. id 6 : 29|0,8,16,21,32,40,48,56,64,72,77,96,112,120,128,136,144,152,160,168,176,184,192,200,216,221,232,240,248,
  287. id 7 : 0|
  288. id 8 : 29|13,29,30,37,45,53,61,69,85,93,101,109,117,118,133,149,165,173,174,181,189,197,205,213,229,230,237,245,253,
  289. id 9 : 0|
  290. id 10 : 29|2,10,26,34,42,50,66,71,82,90,98,106,114,122,127,138,146,154,162,170,183,186,202,210,218,226,234,242,250,
  291. id 11 : 0|
  292. id 12 : 27|7,15,23,24,31,39,47,55,63,79,87,103,119,135,143,151,159,167,175,191,199,207,215,223,224,239,255,
  293. id 13 : 0|
  294. id 14 : 27|4,20,36,52,60,76,84,92,100,108,116,121,132,140,156,172,177,188,196,204,212,220,228,233,236,244,252,
  295. id 15 : 0|
  296. id 16 : 5|134,178,194,238,254,
  297. id 17 : 0|
  298. id 18 : 8|35,51,80,95,111,187,231,247,
  299. id 19 : 0|
  300. id 20 : 7|12,44,88,104,148,164,208,
  301. id 21 : 0|
  302. id 22 : 5|5,65,81,125,217,
  303. id 23 : 0|
  304. id 24 : 7|14,28,58,141,157,171,201,
  305. id 25 : 0|
  306. id 26 : 0|
  307. id 27 : 0|
  308. id 28 : 0|
  309. id 29 : 0|
  310. id 30 : 0|
  311. id 31 : 0|
  312. id 32 : 1|124,
  313. id 33 : 0|
  314. id 34 : 0|
  315. id 35 : 0|
  316. id 36 : 0|
  317. id 37 : 0|
  318.  
  319. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement