-
-
Save CB30/7419a383edf361fd9b738cb90d34cdd2 to your computer and use it in GitHub Desktop.
This is with a set seed. Replace with your seed on line 99. Enjoy!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class AdditionUnderXOR { | |
static final int SS = 1; | |
enum Ore { | |
COAL(60007), | |
IRON(60008), | |
GOLD(60009), | |
REDSTONE(60010), | |
DIAMOND(60011), | |
LAPIS(60012); | |
public final int salt; | |
Ore(int salt) { | |
this.salt = salt; | |
} | |
} | |
enum Disk { | |
SWAMP_CLAY(60014), | |
RIVER_CLAY(60015), | |
GRAVEL(60016); | |
public final int salt; | |
Disk(int salt) { | |
this.salt = salt; | |
} | |
} | |
static long powMod(long base, int pow) { | |
long answer = 1; | |
while (pow != 0) { | |
if ((pow & 1) == 1) | |
answer = (base * answer) & 0xffff_ffff_ffffL; | |
base = (base * base) & 0xffff_ffff_ffffL; | |
pow >>>= 1; | |
} | |
return answer; | |
} | |
/* | |
* Adapted from https://www.geeksforgeeks.org/sorting-a-hashmap-according-to-values/ | |
*/ | |
static HashMap<ArrayList<Long>, Integer> sortByValue(HashMap<ArrayList<Long>, Integer> hm) | |
{ | |
// Create a list from elements of HashMap | |
List<Map.Entry<ArrayList<Long>, Integer> > list = new LinkedList<>(hm.entrySet()); | |
// Sort the list | |
list.sort(Map.Entry.comparingByValue()); | |
// put data from sorted list to hashmap | |
HashMap<ArrayList<Long>, Integer> temp = new LinkedHashMap<>(); | |
for (Map.Entry<ArrayList<Long>, Integer> aa : list) { | |
temp.put(aa.getKey(), aa.getValue()); | |
} | |
return temp; | |
} | |
/* | |
* Adapted from https://www.geeksforgeeks.org/sorting-a-hashmap-according-to-values/ | |
*/ | |
static HashMap<ArrayList<Long>, Integer> sortByValueDescending(HashMap<ArrayList<Long>, Integer> hm) | |
{ | |
// Create a list from elements of HashMap | |
List<Map.Entry<ArrayList<Long>, Integer> > list = new LinkedList<>(hm.entrySet()); | |
// Sort the list | |
list.sort(Map.Entry.comparingByValue()); | |
Collections.reverse(list); | |
// put data from sorted list to hashmap | |
HashMap<ArrayList<Long>, Integer> temp = new LinkedHashMap<>(); | |
for (Map.Entry<ArrayList<Long>, Integer> aa : list) { | |
temp.put(aa.getKey(), aa.getValue()); | |
} | |
return temp; | |
} | |
static HashMap<ArrayList<Long>, Integer> getOffsets(Disk disk, Ore ore) { | |
return getOffsets(disk, ore, false, 0); | |
} | |
static HashMap<ArrayList<Long>, Integer> getOffsets(Disk disk, Ore ore, boolean useResidue, int residue) { | |
HashMap<ArrayList<Long>, Integer> offsets = new HashMap<>(); | |
Random r = new Random(); | |
long targetSalt = ore.salt; | |
long[] measuredSalts = {disk.salt}; // intent is eventually to handle multiple decorators | |
long lmult = 0x5deece66dL; | |
long mask = 0xffff_ffff_ffffL; | |
long seed = 21983982938923L; | |
for (int i = 0; i < SS; i++) { | |
ArrayList<Long> key = new ArrayList<>(measuredSalts.length); | |
for (long salt: measuredSalts) { | |
key.add((((seed + targetSalt) ^ lmult) - ((seed + salt) ^ lmult)) & mask); | |
} | |
if (offsets.containsKey(key)) { | |
int current = offsets.get(key); | |
offsets.replace(key, current + 1); | |
} else { | |
offsets.put(key, 1); | |
} | |
} | |
return offsets; | |
} | |
static boolean residueReliable(Disk disk, Ore ore, int residue) { | |
return getOffsets(disk, ore, true, residue).size() == 1; | |
} | |
static void printTableForPublic(Disk disk, Ore ore, int maxLines) { | |
int total = 0; | |
for (int i = 0; i < 16; i++) //lmao this is terrible | |
if (residueReliable(disk,ore,i)) total++; | |
System.out.println(disk + " " + ore + " will work reliably on " + total / 16.0 * 100 +"% of seeds."); | |
HashMap<ArrayList<Long>, Integer> offsets = getOffsets(disk, ore); | |
int i = 0; | |
for (Map.Entry<ArrayList<Long>, Integer> en : sortByValueDescending(offsets).entrySet()) { | |
if ( i >= maxLines) | |
continue; | |
i++; | |
ArrayList<Long> vecs = en.getKey(); | |
int precision = 16; | |
long blockToSeed = (1L << 48) / precision; | |
long s1 = (vecs.get(0) * 0x5deece66dL) & 0xffff_ffff_ffffL; | |
long s2 = (s1 * 0x5deece66dL) & 0xffff_ffff_ffffL; | |
//long s3 = (s2 * lmult) & mask; //these correspond to the size to depth conversion - too complex | |
//for public | |
//System.out.print( s1 / blockToSeed + " "); | |
System.out.print("Z offset " + s2 / blockToSeed + " occurs with probability "); | |
//System.out.print(s3 / blockToSeed + " "); | |
System.out.println(en.getValue() / (double) SS); | |
} | |
System.out.println(); | |
offsets.clear(); | |
} | |
static void printTableForMe(Disk disk, Ore ore) { | |
HashMap<ArrayList<Long>, Integer> offsets = getOffsets(disk, ore); | |
long lmult = 0x5deece66dL; | |
long mask = 0xffff_ffff_ffffL; | |
for (Map.Entry<ArrayList<Long>, Integer> en : sortByValue(offsets).entrySet()) { | |
ArrayList<Long> vecs = en.getKey(); | |
//for (int call = 0; call < 3; call++) { | |
for (int i = 0; i < vecs.size(); i++) { | |
if (i == 0) { | |
long s1 = (vecs.get(0) * lmult) & mask; | |
long s2 = (s1 * lmult) & mask; | |
long s3 = (s2 * lmult) & mask; | |
System.out.printf("%012X", s1); | |
System.out.print(" " + String.format("%012X", s2)); | |
System.out.print(" " + String.format("%012X", s3)); | |
System.out.println(" " + en.getValue() / (double) SS); | |
} else { | |
long offset = vecs.get(i) - vecs.get(0); | |
long s1 = (offset * lmult) & mask; | |
long s2 = (s1 * lmult) & mask; | |
long s3 = (s2 * lmult) & mask; | |
System.out.printf("%012X", s1); | |
System.out.print(" " + String.format("%012X", s2)); | |
System.out.print(" " + String.format("%012X", s3)); | |
System.out.println(" " + en.getValue() / (double) SS); | |
} | |
} | |
} | |
System.out.println(); | |
offsets.clear(); | |
} | |
public static void main(String[] args) { | |
final int MAX_LINES = 5; | |
for (Disk disk: Disk.values()) { | |
for (Ore ore : Ore.values()) { | |
printTableForPublic(disk, ore, MAX_LINES); | |
} | |
} | |
} | |
} |
It says that my seed is to long but 6459336364121807992 is 100% my seed because it works in amidst etc
did you put an L at the end of the number?
edit: try it in IntelliJ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It says that my seed is to long but 6459336364121807992 is 100% my seed because it works in amidst etc