Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Pokemon Stadium 2 Mystery Gift Decoration Calculator
- // By RainingChain
- #include <iostream>
- #include <array>
- #include <limits>
- #include <iomanip>
- #include <vector>
- #include <unordered_set>
- #include <numeric>
- unsigned char TID_HIGH = 0;
- unsigned char TID_LOW = 0;
- unsigned char ROUND_TWO_UNLOCKED = 1;
- using MyInt = unsigned int;
- MyInt gLCRNGState;
- void seedLCRNG(MyInt seed) {
- gLCRNGState = seed;
- }
- int randLCRNG(void)
- {
- gLCRNGState = (gLCRNGState * 0x19660D) + 0x3C6EF35F;
- return gLCRNGState;
- }
- char selectMysteryGiftItem(unsigned char trainerIdHigh, unsigned char trainerIdLow) {
- int rand;
- char temp;
- unsigned char resultIndex;
- if ((randLCRNG() & 0xFF) < 25u) {
- if ((randLCRNG() & 0xFF) < 50u) {
- if ((randLCRNG() & 0xFF) < 50u) {
- if ((trainerIdHigh & (1 << 7))) {
- resultIndex = 33;
- }
- else {
- resultIndex = 32;
- }
- }
- else {
- resultIndex = ((unsigned char)(trainerIdHigh >> 4)) & 7;
- resultIndex = (resultIndex + 0x18ull) & 0xFF;
- }
- }
- else {
- rand = randLCRNG() & 3;
- temp = (trainerIdHigh & (1 << (rand & 0xFF))) ? 1 : 0;
- temp = (rand << 1) + temp;
- resultIndex = temp;
- resultIndex += 0x10ull;
- }
- }
- else {
- rand = randLCRNG() & 7;
- temp = (trainerIdLow & (1 << (rand & 0xFF))) ? 1 : 0;
- resultIndex = ((rand << 1) + temp) & 0xFF;
- }
- return resultIndex;
- }
- char selectMysteryGiftDecoration(unsigned char trainerIdLow, unsigned char trainerIdHigh, unsigned char roundTwoUnlocked) {
- int rand;
- char temp;
- unsigned char resultIndex;
- if ((randLCRNG() & 0xFF) < 36u) {
- if ((randLCRNG() & 0xFF) < 72u) {
- if ((randLCRNG() & 0xFF) < 72u) {
- rand = randLCRNG() & 0xFF;
- if (rand < 77) {
- resultIndex = roundTwoUnlocked != 0 ? 34 : 36;
- }
- else if (rand < 154) {
- resultIndex = 36;
- }
- else if (trainerIdLow & (1 << 7)) {
- resultIndex = 33;
- }
- else {
- resultIndex = 32;
- }
- }
- else {
- resultIndex = ((unsigned char)(trainerIdLow >> 4)) & 7;
- resultIndex = resultIndex + 24ull;
- }
- }
- else {
- rand = randLCRNG() & 3;
- temp = (trainerIdLow & (1 << (rand & 0xFF))) ? 1 : 0;
- temp = (rand << 1) + temp;
- resultIndex = temp;
- resultIndex += 0x10ull;
- }
- }
- else {
- rand = randLCRNG() & 7;
- temp = (trainerIdHigh & (1 << (rand & 0xFF))) ? 1 : 0;
- resultIndex = ((rand << 1) + temp) & 0xFF;
- }
- return resultIndex;
- }
- std::pair<char, char> getDecoIdx(MyInt osGetCount)
- {
- seedLCRNG(osGetCount);
- randLCRNG(); //selectMysteryGiftResult
- auto a = selectMysteryGiftItem(TID_LOW, TID_HIGH);
- auto b = selectMysteryGiftDecoration(TID_LOW, TID_HIGH, ROUND_TWO_UNLOCKED);
- return { a,b };
- }
- int main()
- {
- std::array<std::vector<unsigned char>, 38> FreqItem = {};
- std::array<std::vector<unsigned char>, 38> FreqDeco = {};
- MyInt osGetCount = std::numeric_limits<MyInt>::min();
- MyInt Max = 255; // std::numeric_limits<MyInt>::max();
- while (true)
- {
- auto pair = getDecoIdx(osGetCount);
- FreqItem[pair.first].push_back(osGetCount);
- FreqDeco[pair.second].push_back(osGetCount);
- if (osGetCount == Max)
- break;
- osGetCount++;
- }
- auto Count = [](const auto& Arr, int start, int end)
- {
- int c = 0;
- for (; start < end; start++)
- c += Arr[start].size();
- return c;
- };
- std::cout << "Frequency items:\n";
- std::cout << " Common:" << Count(FreqItem, 0, 16) << "\n";
- std::cout << " Uncommon:" << Count(FreqItem, 16, 24) << "\n";
- std::cout << " Rare:" << Count(FreqItem, 24, 32) << "\n";
- std::cout << " Ver Rare:" << Count(FreqItem, 32, 38) << "\n";
- for (size_t idx = 0; idx < FreqItem.size(); idx++)
- {
- std::cout << "id " << idx << " : " << FreqItem[idx].size() << "|";
- for (auto seed : FreqItem[idx])
- std::cout << (int)seed << ",";
- std::cout << "\n";
- }
- std::cout << "\n";
- std::cout << "Frequency decos:\n";
- std::cout << " Common:" << Count(FreqDeco, 0, 16) << "\n";
- std::cout << " Uncommon:" << Count(FreqDeco, 16, 24) << "\n";
- std::cout << " Rare:" << Count(FreqDeco, 24, 32) << "\n";
- std::cout << " Ver Rare:" << Count(FreqDeco, 32, 38) << "\n";
- for (size_t idx = 0; idx < FreqDeco.size(); idx++)
- {
- std::cout << "id " << idx << " : " << FreqDeco[idx].size() << "|";
- for (auto seed : FreqDeco[idx])
- std::cout << (int)seed << ",";
- std::cout << "\n";
- }
- return 0;
- }
- unsigned char gLCRNGState2;
- unsigned char randLCRNG2()
- {
- gLCRNGState2 = (gLCRNGState2 * 0x0D) + 0x5F;
- return gLCRNGState2;
- }
- int main2()
- {
- for (int i = 0; i < 256; i++)
- {
- gLCRNGState2 = (unsigned char)i;
- std::vector<unsigned char> Vec;
- Vec.push_back(gLCRNGState2);
- size_t alreadyExistIdx = -1;
- while (true)
- {
- auto NewVal = randLCRNG2();
- for (size_t j = 0; j < Vec.size(); j++)
- {
- if (Vec[j] == NewVal)
- alreadyExistIdx = j;
- }
- Vec.push_back(NewVal);
- if (alreadyExistIdx != -1)
- break;
- }
- std::cout << "Initial seed = " << static_cast<int>(i) << " : ";
- for (size_t j = 0; j < Vec.size(); j++)
- {
- if (j == alreadyExistIdx)
- std::cout << "|Cycle|";
- std::cout << static_cast<int>(Vec[j]) << ",";
- }
- std::cout << "\n";
- }
- return 0;
- }
- /*
- TID= 0;
- Frequency items:
- Common:231
- Uncommon:21
- Rare:3
- Ver Rare:1
- 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,
- id 1 : 0|
- 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,
- id 3 : 0|
- 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,
- id 5 : 0|
- 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,
- id 7 : 0|
- 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,
- id 9 : 0|
- 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,
- id 11 : 0|
- 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,
- id 13 : 0|
- 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,
- id 15 : 0|
- id 16 : 5|24,68,80,180,224,
- id 17 : 0|
- id 18 : 5|77,121,177,221,233,
- id 19 : 0|
- id 20 : 6|18,30,74,118,130,230,
- id 21 : 0|
- id 22 : 5|27,71,127,171,183,
- id 23 : 0|
- id 24 : 3|124,174,227,
- id 25 : 0|
- id 26 : 0|
- id 27 : 0|
- id 28 : 0|
- id 29 : 0|
- id 30 : 0|
- id 31 : 0|
- id 32 : 1|21,
- id 33 : 0|
- id 34 : 0|
- id 35 : 0|
- id 36 : 0|
- id 37 : 0|
- Frequency decos:
- Common:223
- Uncommon:25
- Rare:7
- Ver Rare:1
- 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,
- id 1 : 0|
- 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,
- id 3 : 0|
- 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,
- id 5 : 0|
- 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,
- id 7 : 0|
- 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,
- id 9 : 0|
- 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,
- id 11 : 0|
- 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,
- id 13 : 0|
- 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,
- id 15 : 0|
- id 16 : 5|134,178,194,238,254,
- id 17 : 0|
- id 18 : 8|35,51,80,95,111,187,231,247,
- id 19 : 0|
- id 20 : 7|12,44,88,104,148,164,208,
- id 21 : 0|
- id 22 : 5|5,65,81,125,217,
- id 23 : 0|
- id 24 : 7|14,28,58,141,157,171,201,
- id 25 : 0|
- id 26 : 0|
- id 27 : 0|
- id 28 : 0|
- id 29 : 0|
- id 30 : 0|
- id 31 : 0|
- id 32 : 1|124,
- id 33 : 0|
- id 34 : 0|
- id 35 : 0|
- id 36 : 0|
- id 37 : 0|
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement