-
Notifications
You must be signed in to change notification settings - Fork 0
Pseudorandom Number Generator
PseudoRandom
class provides an API for seeding Pseduo-Generated Random features.
Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returned values are chosen pseudorandomly with (approximately) uniform distribution from that range. When this method is first called, it creates a single new pseudorandom-number generator, exactly as if by the expression.
public static double randomUnitNumberGenerator () {
return random();
}
Returns a pseudorandomly chosen double or integer value between a specifed lowerBound
and upperBound
.
public static double seedRandomDouble (double lowerBound, double upperBound) {
return lowerBound + new Random().nextDouble(upperBound - lowerBound);
}
public static int seedRandomInt (int lowerBound, int upperBound) {
return lowerBound + new Random().nextInt(upperBound - lowerBound);
}
Note: lowerBound
and upperBound
must be positive and finite, lowerBound
must be less than upperBound
.
Selectes an item from a list by pseudo-randomly generating an integer between 0 and the length of the list, and returning the element at this index.
public static <T> T getRandomItem(List<T> items) {
int lenItems = items.size();
int i = seedRandomInt(0, lenItems);
return items.get(i);
}
Map
City
Buildings
Unit Selections
Game User Testing: Theme of Unit Selection & Spell System
Health Bars
In Game menu
- Feature
- User Testing:In Game Menu
Landscape Tile Design Feedback