#include #include #include #include #include #define N 4 typedef uint32_t u32; typedef uint8_t u8; u8 v[N][5]; int d[40]; int np[5]; using namespace std; set p; bool bt(set::iterator it) { if (it == p.end()) { return true; } for (int k=0; k<5; k++) { if (np[k] < 3) { np[k]++; d[*it] = k; bool works = true; for (int i=0; i 1) { works = false; break; } } } if (works && bt(next(it))) { return true; } d[*it] = -1; np[k]--; } } return false; } u32 next_seed(u32 seed) { u32 aux = (seed & 0x80000000) >> 15; seed ^= aux; seed = (seed << 1); seed |= (aux >> 16); return seed & 0xffffffff; } struct ByteRet { u8 byte; u32 seed; }; ByteRet get_byte(u32 seed) { ByteRet ans; ans.byte = 0; for (int i=0; i<8; i++) { ans.byte = (ans.byte << 1); seed = next_seed(seed); ans.byte |= (seed & 1); } ans.seed = seed; return ans; } struct DuelRet { bool first; u8 perm[40]; }; DuelRet get_duel_start(u32 seed) { DuelRet ans; for (int i=0; i<40; i++) { ans.perm[i] = i; } for (int i=0; i<200; i++) { ByteRet a = get_byte(seed); seed = a.seed; ByteRet b = get_byte(seed); seed = b.seed; swap(ans.perm[a.byte % 40], ans.perm[b.byte % 40]); } for (int i=0; i<3200; i++) { seed = next_seed(seed); } ByteRet c = get_byte(seed); ans.first = (c.byte % 2 == 0); return ans; } bool solve(u8 v[4][5], char* deck) { char c[5] = {'D', 'E', 'A', 'T', 'H'}; p.clear(); for (int i=0; i slots; for (int k=0; k<5; k++) { if (k != exodia) { for (int l=0; l<5; l++) { slots.insert(d[k].perm[35+l]); } } } if (slots.size() <= 15) { bool works = true; for (int k=0; k<5; k++) { if (slots.find(d[exodia].perm[35+k]) != slots.end()) { works = false; } } if (works) { int vid = 0; for (int i=0; i<5; i++) { if (i!=exodia) { fillHand(d[i], v[vid]); vid++; } } char deck[40]; if (solve(v, deck)) { printf("strings %08x, couple %08x, boy %08x, joey %08x: %d slots, exodia %d\n", sseed, cseed, bseed, jseed, slots.size(), exodia); for (int i=0; i<5; i++) { printHand(d[i]); } set exodia_slots; for (int i=0; i<5; i++) { exodia_slots.insert(d[exodia].perm[35+i]); } for (int i=0; i<40; i++) { if (exodia_slots.find(i) != exodia_slots.end()) { printf("F "); } else { printf("%c ",deck[i]); } } printf("\n"); } } } } } int main() { u32 strings_seed = 0x03CC0498; u32 aquarium1_seed = 0x0D57A262; u32 aquarium2_seed = 0x2773a716; u32 aquarium3_seed = 0xfa7016e8; u32 joey_seed = 0x32ab1217; DuelRet d[5]; for (int i=0; i<50; i++) { d[4] = get_duel_start(joey_seed); if (d[4].first) { u32 lseed = strings_seed; u32 lseed2 = aquarium1_seed; u32 lseed3 = aquarium2_seed; u32 lseed4 = aquarium3_seed; for (int j=0; j