Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SMWRNG {
- static byte[] rng;
- public static void main(String[] args) {
- rng = new byte[4];
- for (int i = 0; i <= 27776; i++) {
- simulateRNG();
- print(i);
- }
- }
- public static byte simulateRNG() {
- byte y = 1;
- tickRNG(y);
- y--;
- tickRNG(y);
- return rng[2];
- }
- public static void tickRNG(byte y) {
- rng[0] = (byte) (5 * rng[0] + 1);
- boolean c = (rng[1] & 0x80) != 0;
- boolean z = (rng[1] & 0x10) != 0;
- rng[1] = (byte) (2 * rng[1]);
- if (c == z) {
- rng[1]++;
- }
- rng[2+y] = (byte) (rng[0] ^ rng[1]);
- }
- public static void print(int i) {
- System.out.printf("%5d) S: %s, T: %s, J: %s, K: %s%n", i, b2s(rng[0]), b2s(rng[1]), b2s(rng[2]), b2s(rng[3]));
- }
- public static String b2s(byte b) {
- return String.format("%2x", b).toUpperCase().replace(' ', '0');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement