From af90cb7f73cc8f0f73968852137772572a3425af Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 4 May 2017 16:41:01 -0400 Subject: [PATCH] v0.6.0: switched to linked hash map to make rng deterministic --- .../shatteredpixeldungeon/items/Generator.java | 3 ++- .../levels/rooms/connection/ConnectionRoom.java | 3 ++- .../levels/rooms/standard/StandardRoom.java | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java index d81fdd0ab..1b810f11e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Generator.java @@ -151,6 +151,7 @@ import com.watabou.utils.Random; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.LinkedHashMap; public class Generator { @@ -201,7 +202,7 @@ public class Generator { {0, 2, 8, 20, 70} }; - private static HashMap categoryProbs = new HashMap(); + private static HashMap categoryProbs = new LinkedHashMap<>(); private static final float[] INITIAL_ARTIFACT_PROBS = new float[]{ 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1}; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/ConnectionRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/ConnectionRoom.java index 696f2d692..1127b1499 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/ConnectionRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/ConnectionRoom.java @@ -26,6 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.watabou.utils.Random; import java.util.HashMap; +import java.util.LinkedHashMap; public abstract class ConnectionRoom extends Room { @@ -49,7 +50,7 @@ public abstract class ConnectionRoom extends Room { else return 4; } - private static HashMap, Float> chances = new HashMap<>(); + private static HashMap, Float> chances = new LinkedHashMap<>(); static { chances.put(TunnelRoom.class, 10f); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java index 873517621..383c00cf7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java @@ -26,6 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.watabou.utils.Random; import java.util.HashMap; +import java.util.LinkedHashMap; public abstract class StandardRoom extends Room { @@ -72,12 +73,12 @@ public abstract class StandardRoom extends Room { else return 4; } - private static HashMap, Float> chances = new HashMap<>(); + private static HashMap, Float> chances = new LinkedHashMap<>(); static { chances.put(EmptyRoom.class, 24f); - chances.put(PlatformRoom.class, 1f); + chances.put(PlatformRoom.class, 1f); chances.put(BurnedRoom.class, 1f); chances.put(FissureRoom.class, 1f); chances.put(GrassyGraveRoom.class, 1f);