Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- #include <cmath>
- #include <string>
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- #define FILL << std::setw(5) <<
- #define FILL2 << std::setw(2) <<
- #define SPC << " " <<
- const int SIZE=20000;
- int main()
- {
- std::ofstream fi ("blackjack.txt", std::ofstream::out);
- uint16_t rng, rng2=0x3ff;
- int ub, lb;
- int array[52];
- int blackjack[SIZE];
- int bjnextindex[SIZE];
- uint16_t bjrng[SIZE];
- int bjrep[SIZE];
- int bjcount=0;
- int bit;
- //int index=0;
- for(int index=0;index<=SIZE;index++)
- {
- rng=rng2; //rng2 is starting rng
- //setup array
- for(int i=0;i<=51;i++) array[i]=51-i;
- int shuffle=0, repeats=0, pos;
- //shuffle by performing 52 swaps
- while(1)
- {
- //cycle rng 6 times
- for(int i=0;i<6;i++) {bit=(rng^(rng>>2)^(rng>>11)^(rng>>15))&1; rng=(rng<<1)+bit;}
- pos=rng%64;
- if(pos>=52) { repeats++; continue;} //if >=52, repeat; otherwise swap position shuffle and pos
- std::swap(array[pos],array[shuffle]);
- shuffle++;
- if(shuffle>=52) break;
- }
- //check for blackjack
- //array[1] and array[3] must be A and KQJT in either order
- //array[0] and array[2] must not be blackjack
- //A: <=3 ten-card: >=36
- if((array[1]<=3 && array[3]>=36) || (array[1]>=36 && array[3]<=3))
- if( !((array[0]<=3 && array[2]>=36) || (array[0]>=36 && array[2]<=3)) )
- {
- //blackjack
- //fi << std::dec << std::setfill('0') << std::setw(5) << index << " "
- // << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << rng2 << " "
- // << std::dec << 390+6*repeats << " " << 390+6*repeats+index << "\n";
- blackjack[bjcount]=index;
- bjnextindex[bjcount]=390+6*repeats+index;
- bjrng[bjcount]=rng2;
- bjcount++;
- /*
- for(int i=0;i<=51;i++)
- fi << std::hex << array[i] << " ";
- fi << "\n";
- */
- }
- //check next rng2
- bit=(rng2^(rng2>>2)^(rng2>>11)^(rng2>>15))&1;
- rng2=(rng2<<1)+bit;
- }
- //run over blackjacks to find next delay
- for(int i=0;i<bjcount;i++)
- {
- int j=i;
- do
- {
- j++;
- } while(j<bjcount-1 && blackjack[j]<bjnextindex[i]);
- fi << std::dec << std::setfill('0') << std::setw(5) << blackjack[i] << " "
- << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << bjrng[i] << " "
- << std::dec << bjnextindex[i] << " " << blackjack[j] << " " << blackjack[j]-bjnextindex[i] << "\n";
- }
- fi.close();
- printf("Done!");
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement