private void setFresh(final int x, final int y, double counter) { if (x < 0 || x >= width || y < 0 || y >= height || gradientMap[x][y] < counter) return; gradientMap[x][y] = counter; fresh.add(encode(x, y)); }
protected void setFresh(final int pt, double counter) { if (!initialized || !adjacency.validate(pt)) return; if(gradientMap[pt] < counter && gradientMap[pt] < FLOOR) return; gradientMap[pt] = counter; fresh.add(pt); }
public int add(final K k) { final int pos = insert(k); if (pos < 0) return defRetValue; final IntVLA oldValue = value[pos]; oldValue.add(order.size - 1); return order.size - 1; }
protected void fixValues() { for (int i = 0; i < order.size; i++) { value[order.items[i]].clear(); } for (int i = 0; i < order.size; i++) { value[order.items[i]].add(i); } }
/** * Marks a cell as a goal for pathfinding, unless the cell is a wall or unreachable area (then it does nothing). * * @param x * @param y */ public void setGoal(int x, int y) { if (!initialized || x < 0 || x >= width || y < 0 || y >= height) return; if (physicalMap[x][y] > FLOOR) { return; } goals.add(encode(x, y)); gradientMap[x][y] = 0.0; }
/** * Marks many cells as goals for pathfinding, ignoring cells in walls or unreachable areas. Possibly more efficient * than a loop that calls {@link #setGoal(Coord)} over and over, since this doesn't need to do a bounds check. The * GreasedRegion passed to this should have the same (or smaller) width and height as this DijkstraMap. * * @param pts a GreasedRegion containing "on" cells to treat as goals; should have the same width and height as this */ public void setGoals(GreasedRegion pts) { if (!initialized || pts.width > width || pts.height > height) return; for(Coord c : pts) { if(physicalMap[c.x][c.y] <= FLOOR) { goals.add(encode(c)); gradientMap[c.x][c.y] = 0.0; } } }
private void setFresh(final Coord pt, double counter) { if (!pt.isWithin(width, height) || gradientMap[pt.x][pt.y] < counter) return; gradientMap[pt.x][pt.y] = counter; fresh.add(encode(pt)); }
public IntVLA valuesAsList() { IntVLA ls = new IntVLA(size); for (int i = 0; i < size; i++) { ls.add(getAt(i)); } return ls; }
/** * Marks a cell as a goal for pathfinding, unless the cell is a wall or unreachable area (then it does nothing). * * @param pt */ public void setGoal(Coord pt) { if (!initialized || !pt.isWithin(width, height)) return; if (physicalMap[pt.x][pt.y] > FLOOR) { return; } goals.add(encode(pt)); gradientMap[pt.x][pt.y] = 0.0; } /**
/** * Get a list of the independent results of n rolls of dice with the given * number of sides. * * @param n number of dice used * @param sides positive integer; number of sides on each die * @return list of results */ public IntVLA independentRolls(int n, int sides) { IntVLA ret = new IntVLA(n); for (int i = 0; i < n; i++) { ret.add(rng.nextInt(sides) + 1); } return ret; }
/** * Equivalent to {@link #add(Object)}, except that it can place k at any point in the ordering (shifting up later * entries and changing their values to match their new positions in the ordering). * @param idx the position in the ordering to place k at; will not be used if negative or greater than the current size (it can be equal to the current size) * @param k the key to add into this MultiArrangement; its value will be idx * @return the previous position in the ordering that k had if already present, the previous size of the MultiArrangement if k was just added now, or -1 if idx is invalid */ public int addAt(final int idx, final K k) { if(idx < 0 || idx > order.size) return -1; final int pos = insertAt(k, idx); if (pos < 0) return defRetValue; final IntVLA oldValue = value[pos]; oldValue.add(idx); fixValues(); return idx; }
/** * Rolls the given number of exploding dice with the given number of sides and returns * the total of the lowest n dice (counting a die that explodes as one die). * * @param n number of worst dice to total * @param dice total number of dice to roll * @param sides number of sides on the dice * @return sum of worst n out of <em>dice</em><b>d</b><em>sides</em> */ private int worstOfExploding(int n, int dice, int sides) { int rolls = Math.min(n, dice); temp.clear(); for (int i = 0; i < dice; i++) { temp.add(rollExplodingDice(1, sides)); } return worstOf(rolls, temp); }
public IntVLA getMany(Iterable<? extends K> keys) { if(keys == null) return new IntVLA(); IntVLA vals = new IntVLA(); for(K k : keys) { vals.add(getInt(k)); } return vals; }
/** * Rolls the given number of dice with the given number of sides and returns * the total of the best n dice. * * @param n number of best dice to total * @param dice total number of dice to roll * @param sides number of sides on the dice * @return sum of best n out of <em>dice</em><b>d</b><em>sides</em> */ private int bestOf(int n, int dice, int sides) { int rolls = Math.min(n, dice); temp.clear(); for (int i = 0; i < dice; i++) { temp.add(rollDice(1, sides)); } return bestOf(rolls, temp); }
/** * Find the best n totals from the provided number of dice rolled according * to the roll group string. * * @param n number of roll groups to total * @param dice number of roll groups to roll * @param group string encoded roll grouping * @return the sum */ public int bestOf(int n, int dice, String group) { int rolls = Math.min(n, dice); temp.clear(); for (int i = 0; i < dice; i++) { temp.add(roll(group)); } return bestOf(rolls, temp); }
/** * Find the worst n totals from the provided number of dice rolled according * to the roll group string. * * @param n number of roll groups to total * @param dice number of roll groups to roll * @param group string encoded roll grouping * @return the sum */ public int worstOf(int n, int dice, String group) { int rolls = Math.min(n, dice); temp.clear(); for (int i = 0; i < dice; i++) { temp.add(roll(group)); } return worstOf(rolls, temp); }
/** * Rolls the given number of exploding dice with the given number of sides and returns * the total of the best n dice (counting a die that explodes as one die). * * @param n number of best dice to total * @param dice total number of dice to roll * @param sides number of sides on the dice * @return sum of best n out of <em>dice</em><b>d</b><em>sides</em> */ private int bestOfExploding(int n, int dice, int sides) { int rolls = Math.min(n, dice); temp.clear(); for (int i = 0; i < dice; i++) { temp.add(rollExplodingDice(1, sides)); } return bestOf(rolls, temp); }
public IntVLA getMany(int... keys) { if(keys == null) return new IntVLA(1); final int len = keys.length; IntVLA vals = new IntVLA(len); for (int i = 0; i < len; i++) { vals.add(get(keys[i])); } return vals; } /**
/** * Given the zones resulting from this class' calculate method and a Coord to check, finds the indices of all * influencing groups in zones that have the Coord in their area, and returns all such indices as an int array. * @param zones a short[][] returned by calculate; not a multi-packed short[][] from CoordPacker ! * @param point the Coord to test * @return an int[] where each element is the index of an influencing group in zones */ public int[] nearestInfluences(GreasedRegion[] zones, Coord point) { IntVLA found = new IntVLA(4); for (int i = 0; i < zones.length; i++) { if(zones[i].contains(point)) found.add(i); } return found.toArray(); } /**