public RandomBias(IRNG rng) { this.rng = rng; biases = new OrderedMap<>(32); } public RandomBias(IRNG rng, Map<String, Double> mapping)
/** * Constructs a SpatialMap with the given capacity * @param capacity the capacity for each of the internal OrderedMaps */ public SpatialMap(int capacity) { itemMapping = new OrderedMap<>(capacity); positionMapping = new OrderedMap<>(capacity); }
/** * Construct a SoundMap without a level to actually scan. This constructor allows you to specify an RNG before it is * used. If you use this constructor, you must call an initialize() method before using this class. */ public SoundMap(IRNG random) { rng = random; alerted = new OrderedMap<>(); fresh = new OrderedMap<>(); sounds = new OrderedMap<>(); }
/** * Constructs a SpatialMap with capacity 32. */ public SpatialMap() { itemMapping = new OrderedMap<>(32); positionMapping = new OrderedMap<>(32); }
/** * Makes an empty OrderedMap (OM); needs key and value types to be specified in order to work. For an empty * OrderedMap with String keys and Coord values, you could use {@code Maker.<String, Coord>makeOM()}. Using * the new keyword is probably just as easy in this case; this method is provided for completeness relative to * makeOM() with 2 or more parameters. * @param <K> the type of keys in the returned OrderedMap; cannot be inferred and must be specified * @param <V> the type of values in the returned OrderedMap; cannot be inferred and must be specified * @return an empty OrderedMap with the given key and value types. */ public static <K, V> OrderedMap<K, V> makeOM() { return new OrderedMap<>(); }
/** * Makes an empty OrderedMap (OM); needs key and value types to be specified in order to work. For an empty * OrderedMap with String keys and Coord values, you could use {@code Maker.<String, Coord>makeOM()}. Using * the new keyword is probably just as easy in this case; this method is provided for completeness relative to * makeMap() with 2 or more parameters. * @param <K> the type of keys in the returned OrderedMap; cannot be inferred and must be specified * @param <V> the type of values in the returned OrderedMap; cannot be inferred and must be specified * @return an empty OrderedMap with the given key and value types. */ public static <K, V> OrderedMap<K, V> makeMap() { return new OrderedMap<>(); }
/** * Construct a SoundMap without a level to actually scan. If you use this constructor, you must call an * initialize() method before using this class. */ public SoundMap() { rng = new GWTRNG(); alerted = new OrderedMap<>(); fresh = new OrderedMap<>(); sounds = new OrderedMap<>(); }
/** * Used to construct a SoundMap from the output of another. Any sounds will need to be assigned again. * @param level */ public SoundMap(final double[][] level) { rng = new GWTRNG(); alerted = new OrderedMap<>(); fresh = new OrderedMap<>(); sounds = new OrderedMap<>(); initialize(level); } /**
/** * Used to construct a DijkstraMap from the output of another, specifying a distance calculation. * @param level * @param measurement */ public SoundMap(final double[][] level, Measurement measurement) { rng = new GWTRNG(); this.measurement = measurement; alerted = new OrderedMap<>(); fresh = new OrderedMap<>(); sounds = new OrderedMap<>(); initialize(level); }
/** * Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other * char[][] where '#' means a wall and anything else is a walkable tile. If you only have * a map that uses box-drawing characters, use DungeonUtility.linesToHashes() to get a * map that can be used here. * * @param level */ public SoundMap(final char[][] level) { rng = new GWTRNG(); alerted = new OrderedMap<>(); fresh = new OrderedMap<>(); sounds = new OrderedMap<>(); initialize(level); } /**
/** * Constructs a new Thesaurus with an unseeded RNG used to shuffle word order. */ public Thesaurus() { mappings = new OrderedMap<>(256, Hashers.caseInsensitiveStringHasher); rng = new GWTRNG(); }
public RandomBias() { biases = new OrderedMap<>(32); rng = new GWTRNG(); } public RandomBias(IRNG rng)
public RandomBias(IRNG rng, Map<String, Double> mapping, int distribution) { this.rng = rng; this.distribution = distribution; if (mapping == null) { biases = new OrderedMap<>(32); } else { biases = new OrderedMap<>(mapping.size()); double exp; for (Map.Entry<String, Double> kv : mapping.entrySet()) { exp = kv.getValue(); if (exp <= 0) exp = 0.001; if (exp >= 1) exp = 0.999; biases.put(kv.getKey(), exp); } } }
/** * Constructs a new Thesaurus, seeding its RNG (used to shuffle word order) with shuffleSeed. * @param shuffleSeed a long for seeding this class' RNG */ public Thesaurus(long shuffleSeed) { mappings = new OrderedMap<>(256, Hashers.caseInsensitiveStringHasher); this.rng = new GWTRNG(shuffleSeed); }
protected static OrderedMap<Coord, List<Coord>> listToMap(List<Coord> sequence) { OrderedMap<Coord, List<Coord>> conns = new OrderedMap<>(sequence.size() - 1); for (int i = 0; i < sequence.size() - 1; i++) { Coord c1 = sequence.get(i), c2 = sequence.get(i+1); List<Coord> cs = new ArrayList<>(1); cs.add(c2); conns.put(c1, cs); } return conns; } protected static OrderedMap<Coord, List<Coord>> setToMap(OrderedSet<Coord> sequence)
@Override public OrderedMap<Coord, Double> findArea() { OrderedMap<Coord, Double> ret = new OrderedMap<>(1); ret.put(Coord.get(center.x, center.y), 1.0); return ret; }
/** * Constructs a new Thesaurus, seeding its RNG (used to shuffle word order) with the next long from the given RNG. * @param rng an RNG that will only be used to get one long (for seeding this class' RNG) */ public Thesaurus(IRNG rng) { mappings = new OrderedMap<>(256, Hashers.caseInsensitiveStringHasher); this.rng = new GWTRNG(rng.nextLong()); }
/** * Constructs a new Thesaurus, seeding its RNG (used to shuffle word order) with shuffleSeed. * @param shuffleSeed a String for seeding this class' RNG */ public Thesaurus(String shuffleSeed) { mappings = new OrderedMap<>(256, Hashers.caseInsensitiveStringHasher); this.rng = new GWTRNG(CrossHash.hash64(shuffleSeed)); }
protected static OrderedMap<Coord, List<Coord>> setToMap(OrderedSet<Coord> sequence) { OrderedMap<Coord, List<Coord>> conns = new OrderedMap<>(sequence.size() - 1); for (int i = 0; i < sequence.size() - 1; i++) { Coord c1 = sequence.getAt(i), c2 = sequence.getAt(i+1); List<Coord> cs = new ArrayList<>(1); cs.add(c2); conns.put(c1, cs); } return conns; }
@Override @SuppressWarnings("unchecked") public OrderedMap read(Json json, JsonValue jsonData, Class type) { if(jsonData == null || jsonData.isNull()) return null; float f = json.readValue("f", float.class, jsonData); Object k = json.readValue("k", null, INVALID, jsonData); Object v = json.readValue("v", null, INVALID, jsonData); Object[] r = json.readValue("r", Object[].class, jsonData); if(k == INVALID) return new OrderedMap(0, f); return Maker.makeOM(f, k, v, r); //return new OrderedMap(json.readValue(OrderedSet.class, jsonData.get("k")), // json.readValue(ArrayList.class, jsonData.get("v")), jsonData.getFloat("f")); } });