|
RuneHive-Game
|
A static-util class that provides additional functionality for generating pseudo-random numbers. More...
Static Public Member Functions | |
| static float | floatRandom (float range) |
Returns a pseudo-random float between inclusive 0 and exclusive range. | |
| static double | inclusive (double min, double max) |
Returns a pseudo-random int value between inclusive min and inclusive max. | |
| static int | inclusive (int min, int max) |
Returns a pseudo-random int value between inclusive min and inclusive max. | |
| static int | inclusive (int range) |
Returns a pseudo-random int value between inclusive 0 and inclusive range. | |
| static int | inclusiveExcludes (int min, int max, int... exclude) |
Returns a pseudo-random int value between inclusive min and inclusive max excluding the specified numbers within the excludes array. | |
| static boolean | nextBoolean () |
Returns a pseudo-random boolean. | |
| static double | nextDouble () |
Returns a pseudo-random double. | |
| static boolean | random (boolean... array) |
Pseudo-randomly retrieves an boolean from this array. | |
| static byte | random (byte... array) |
Pseudo-randomly retrieves an byte from this array. | |
| static char | random (char... array) |
Pseudo-randomly retrieves an char from this array. | |
| static double | random (double... array) |
Pseudo-randomly retrieves an double from this array. | |
| static float | random (float... array) |
Pseudo-randomly retrieves an float from this array. | |
| static int | random (int... array) |
Pseudo-randomly retrieves an int from this array. | |
| static< T > T | random (List< T > list) |
Pseudo-randomly retrieves a element from list. | |
| static long | random (long... array) |
Pseudo-randomly retrieves an long from this array. | |
| static short | random (short... array) |
Pseudo-randomly retrieves an short from this array. | |
| static< T > T | random (T[] array) |
Pseudo-randomly retrieves a element from array. | |
| static< T > T | randomExclude (T[] array, T exclude) |
Returns a pseudo-random int value between inclusive min and inclusive max excluding the specified numbers within the excludes array. | |
| static boolean[] | shuffle (boolean[] array) |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an boolean array. | |
| static byte[] | shuffle (byte[] array) |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an byte array. | |
| static char[] | shuffle (char[] array) |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an char array. | |
| static double[] | shuffle (double[] array) |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an double array. | |
| static float[] | shuffle (float[] array) |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an float array. | |
| static int[] | shuffle (int[] array) |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an int array. | |
| static long[] | shuffle (long[] array) |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an long array. | |
| static short[] | shuffle (short[] array) |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an short array. | |
| static< T > T[] | shuffle (T[] array) |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an T array. | |
| static boolean | success (double value) |
Determines if a pseudorandomly generated double rounded to two decimal places is below or equal to value. | |
Private Member Functions | |
| RandomUtils () | |
| A private constructor to discourage external instantiation. | |
A static-util class that provides additional functionality for generating pseudo-random numbers.
All functions in this class are backed by ThreadLocalRandom rather than the more commonly used Random. It is generally preferred to use this over Random because although Random is thread safe; the same seed is shared concurrently, which leads to contention between multiple threads and overhead as a result. Surprisingly because of the way that works, even in completely single-threaded situations it runs up to three times faster than
ThreadLocalRandom.
Random
Definition at line 22 of file RandomUtils.java.
|
private |
A private constructor to discourage external instantiation.
Definition at line 27 of file RandomUtils.java.
|
static |
Returns a pseudo-random float between inclusive 0 and exclusive range.
| range | The exclusive range. |
float. | IllegalArgumentException | If the specified range is less than 0. |
Definition at line 56 of file RandomUtils.java.
|
static |
Returns a pseudo-random int value between inclusive min and inclusive max.
| min | The minimum inclusive number. |
| max | The maximum inclusive number. |
int. | IllegalArgumentException | If max - min + 1 is less than 0. |
Definition at line 87 of file RandomUtils.java.
|
static |
Returns a pseudo-random int value between inclusive min and inclusive max.
| min | The minimum inclusive number. |
| max | The maximum inclusive number. |
int. | IllegalArgumentException | If max - min + 1 is less than 0. |
Definition at line 70 of file RandomUtils.java.
Referenced by com.runehive.content.bot.botclass.impl.AGSRuneMelee.block(), com.runehive.content.bot.botclass.impl.PureMelee.block(), com.runehive.content.bot.botclass.impl.PureRangeMelee.block(), com.runehive.content.bot.botclass.impl.WelfareRuneMelee.block(), com.runehive.content.bot.botclass.impl.ZerkerMelee.block(), com.runehive.content.activity.impl.zulrah.ZulrahActivity.cloudEffect(), com.runehive.content.skill.impl.farming.patches.HarvestablePatch.createHarvestAction(), com.runehive.content.shootingstar.ShootingStarData.decreaseDust(), com.runehive.game.world.entity.mob.npc.drop.NpcDropTable.generate(), com.runehive.game.world.entity.combat.CombatUtil.generateDragonfire(), com.runehive.game.world.entity.combat.strategy.npc.boss.Venenatis.PrayerDrain.getHits(), com.runehive.content.shootingstar.ShootingStarData.getLevel(), com.runehive.content.bot.botclass.impl.AGSRuneMelee.hit(), com.runehive.content.bot.botclass.impl.PureMelee.hit(), com.runehive.content.bot.botclass.impl.PureRangeMelee.hit(), com.runehive.content.bot.botclass.impl.WelfareRuneMelee.hit(), com.runehive.content.bot.botclass.impl.ZerkerMelee.hit(), com.runehive.game.world.entity.combat.strategy.npc.boss.Vetion.Earthquake.hit(), inclusive(), inclusiveExcludes(), com.runehive.content.bot.objective.impl.WildernessDitchObjective.init(), com.runehive.content.bot.objective.impl.WildernessWalkObjective.init(), com.runehive.game.world.entity.combat.attack.FormulaFactory.nextHit(), com.runehive.game.world.entity.combat.attack.listener.other.PrayerListener.preDeath(), com.runehive.game.world.entity.mob.npc.Npc.sequence(), com.runehive.content.shootingstar.ShootingStarData.ShootingStarData(), com.runehive.game.world.entity.MobList< E extends Mob >.shuffle(), and com.runehive.content.activity.randomevent.RandomEventHandler.trigger().
|
static |
Returns a pseudo-random int value between inclusive 0 and inclusive range.
| range | The maximum inclusive number. |
int. | IllegalArgumentException | If max - min + 1 is less than 0. |
Definition at line 101 of file RandomUtils.java.
References inclusive().
|
static |
Returns a pseudo-random int value between inclusive min and inclusive max excluding the specified numbers within the excludes array.
| min | the minimum inclusive number. |
| max | the maximum inclusive number. |
int. | IllegalArgumentException | if max - min + 1 is less than 0. |
Definition at line 359 of file RandomUtils.java.
References inclusive().
Referenced by com.runehive.game.world.entity.combat.magic.MagicImpact.kbdShock().
|
static |
Returns a pseudo-random boolean.
boolean. Definition at line 35 of file RandomUtils.java.
|
static |
Returns a pseudo-random double.
double. Definition at line 44 of file RandomUtils.java.
|
static |
Pseudo-randomly retrieves an boolean from this array.
| array | The array to retrieve an boolean from. |
boolean retrieved from the array. Definition at line 181 of file RandomUtils.java.
|
static |
Pseudo-randomly retrieves an byte from this array.
| array | The array to retrieve an byte from. |
byte retrieved from the array. Definition at line 161 of file RandomUtils.java.
|
static |
Pseudo-randomly retrieves an char from this array.
| array | The array to retrieve an char from. |
char retrieved from the array. Definition at line 191 of file RandomUtils.java.
|
static |
Pseudo-randomly retrieves an double from this array.
| array | The array to retrieve an double from. |
double retrieved from the array. Definition at line 141 of file RandomUtils.java.
|
static |
Pseudo-randomly retrieves an float from this array.
| array | The array to retrieve an float from. |
float retrieved from the array. Definition at line 171 of file RandomUtils.java.
|
static |
Pseudo-randomly retrieves an int from this array.
| array | The array to retrieve an int from. |
int retrieved from the array. Definition at line 121 of file RandomUtils.java.
|
static |
Pseudo-randomly retrieves a element from list.
| list | The list to retrieve an element from. |
Definition at line 201 of file RandomUtils.java.
|
static |
Pseudo-randomly retrieves an long from this array.
| array | The array to retrieve an long from. |
long retrieved from the array. Definition at line 131 of file RandomUtils.java.
|
static |
Pseudo-randomly retrieves an short from this array.
| array | The array to retrieve an short from. |
short retrieved from the array. Definition at line 151 of file RandomUtils.java.
|
static |
Pseudo-randomly retrieves a element from array.
| array | The array to retrieve an element from. |
Definition at line 111 of file RandomUtils.java.
Referenced by com.runehive.game.world.entity.combat.strategy.npc.boss.MutantTarn.canAttack(), com.runehive.game.world.entity.combat.strategy.npc.boss.Vorkath.canAttack(), com.runehive.content.bot.objective.impl.BankObjective.finish(), com.runehive.game.world.entity.combat.strategy.npc.boss.Vetion.finishIncoming(), com.runehive.game.world.entity.mob.npc.drop.NpcDropTable.generate(), com.runehive.game.world.pathfinding.TraversalMap.getRandomNonDiagonal(), com.runehive.game.world.pathfinding.TraversalMap.getRandomTraversableTile(), com.runehive.content.activity.infernomobs.JalTokJad.hit(), com.runehive.game.world.entity.combat.strategy.npc.boss.scorpia.Scorpia.hit(), com.runehive.content.bot.objective.impl.BankObjective.init(), com.runehive.content.bot.objective.impl.RestockObjective.init(), com.runehive.game.world.entity.combat.strategy.npc.boss.MutantTarn.init(), com.runehive.game.world.entity.combat.strategy.npc.boss.Vorkath.init(), randomExclude(), com.runehive.game.world.entity.combat.CombatUtil.randomStrategy(), com.runehive.content.activity.impl.pestcontrol.PestControlGame.spawn(), com.runehive.content.activity.impl.fightcaves.FightCaves.start(), com.runehive.content.activity.impl.recipefordisaster.RecipeForDisaster.start(), com.runehive.content.activity.inferno.Inferno.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.Vetion.Magic.start(), com.runehive.game.world.entity.combat.strategy.npc.boss.MutantTarn.withinDistance(), and com.runehive.game.world.entity.combat.strategy.npc.boss.Vorkath.withinDistance().
|
static |
Returns a pseudo-random int value between inclusive min and inclusive max excluding the specified numbers within the excludes array.
int. | IllegalArgumentException | if max - min + 1 is less than 0. |
Definition at line 378 of file RandomUtils.java.
References random().
Referenced by com.runehive.game.world.entity.combat.strategy.npc.boss.Venenatis.Web.finishOutgoing(), com.runehive.game.world.entity.combat.strategy.npc.boss.DemonicGorillas.getNextForm(), com.runehive.game.world.entity.combat.strategy.npc.boss.DemonicGorillas.getNextStrategy(), com.runehive.game.world.entity.combat.strategy.npc.boss.Hydra.getNextStrategy(), com.runehive.content.activity.impl.zulrah.ZulrahActivity.nextForm(), and com.runehive.game.world.entity.combat.strategy.npc.boss.StoneGuardian.nextForm().
|
static |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an boolean array.
| array | The array that will be shuffled. |
Definition at line 324 of file RandomUtils.java.
|
static |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an byte array.
| array | The array that will be shuffled. |
Definition at line 292 of file RandomUtils.java.
|
static |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an char array.
| array | The array that will be shuffled. |
Definition at line 339 of file RandomUtils.java.
|
static |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an double array.
| array | The array that will be shuffled. |
Definition at line 260 of file RandomUtils.java.
|
static |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an float array.
| array | The array that will be shuffled. |
Definition at line 308 of file RandomUtils.java.
|
static |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an int array.
| array | The array that will be shuffled. |
Definition at line 228 of file RandomUtils.java.
|
static |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an long array.
| array | The array that will be shuffled. |
Definition at line 244 of file RandomUtils.java.
|
static |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an short array.
| array | The array that will be shuffled. |
Definition at line 276 of file RandomUtils.java.
|
static |
An implementation of the Fisher-Yates shuffle algorithm that will shuffle the elements of an T array.
| array | The array that will be shuffled. |
Definition at line 212 of file RandomUtils.java.
|
static |
Determines if a pseudorandomly generated double rounded to two decimal places is below or equal to value.
| value | the value to determine this for. |
true if successful, false otherwise. Definition at line 392 of file RandomUtils.java.
Referenced by com.runehive.game.world.entity.combat.strategy.npc.NpcMeleeStrategy.attack(), com.runehive.game.world.entity.combat.strategy.npc.NpcRangedStrategy.attack(), com.runehive.game.world.entity.combat.strategy.player.custom.ToxicBlowpipeStrategy.attack(), com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.Justiciar.block(), com.runehive.game.world.entity.combat.strategy.npc.boss.magearena.Porazdir.block(), com.runehive.content.skill.impl.firemaking.Firemaking.bonfireAction(), com.runehive.game.world.entity.combat.strategy.npc.boss.Callisto.canAttack(), com.runehive.content.skill.impl.woodcutting.WoodcuttingAction.chop(), com.runehive.game.world.entity.combat.attack.listener.npc.GeneralGraardor.MeleeAttack.finishOutgoing(), com.runehive.game.world.entity.combat.strategy.npc.boss.Callisto.finishOutgoing(), com.runehive.game.world.entity.combat.strategy.npc.boss.Vetion.finishOutgoing(), com.runehive.content.skill.impl.fishing.FishingAction.fish(), com.runehive.content.bot.botclass.impl.AGSRuneMelee.hit(), com.runehive.content.bot.botclass.impl.PureRangeMelee.hit(), com.runehive.content.bot.botclass.impl.ZerkerMelee.hit(), com.runehive.game.world.entity.combat.strategy.player.custom.TridentOfTheSwampStrategy.hit(), com.runehive.game.world.entity.combat.strategy.player.PlayerMagicStrategy.hit(), com.runehive.game.world.entity.combat.attack.listener.item.VeracListener.init(), com.runehive.game.world.entity.combat.attack.FormulaFactory.isAccurate(), com.runehive.game.world.entity.combat.attack.listener.item.ZulrahHelm.magma(), com.runehive.content.skill.impl.mining.MiningAction.mine(), com.runehive.content.skill.impl.firemaking.FiremakingAction.onDestruct(), com.runehive.game.world.entity.combat.strategy.player.custom.ToxicBlowpipeStrategy.removeAmmunition(), com.runehive.game.world.entity.combat.strategy.player.PlayerRangedStrategy.removeAmmunition(), com.runehive.game.world.entity.combat.strategy.npc.NpcMagicStrategy.sendProjectile(), com.runehive.game.world.entity.combat.attack.listener.item.ZulrahHelm.serp(), com.runehive.content.skill.SkillRepository.spawn(), com.runehive.game.world.entity.combat.attack.listener.npc.DarkBeast.start(), com.runehive.game.world.entity.combat.attack.listener.npc.GeneralGraardor.start(), com.runehive.game.world.entity.combat.strategy.player.PlayerMagicStrategy.start(), and com.runehive.game.world.entity.combat.attack.listener.item.ZulrahHelm.tanz().