public class Utils
extends java.lang.Object
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static int |
argmax(double[] values) |
static Vector2d |
choice(java.util.ArrayList<Vector2d> elements,
java.util.Random rnd) |
static int |
choice(int[] elements,
java.util.Random rnd) |
static java.lang.Object |
choice(java.lang.Object[] elements,
java.util.Random rnd) |
static Direction |
choiceDir(java.util.ArrayList<Direction> elements,
java.util.Random rnd) |
static int |
findMaxDivisor(int value) |
static java.lang.String |
formatString(java.lang.String str) |
static double |
noise(double input,
double epsilon,
double random)
Adds a small noise to the input value.
|
static double |
normalise(double a_value,
double a_min,
double a_max) |
static Direction |
processMovementActionKeys(boolean[] key_pressed,
int idx) |
static boolean |
processUseKey(boolean[] key_pressed,
int idx) |
static java.lang.String[][] |
readGames(java.lang.String filename)
Processes a file with game names (containing full path).
|
static java.awt.Polygon |
roundedPoints(java.awt.Rectangle rect) |
static java.lang.String |
toStringArray(java.lang.String[] array) |
static java.awt.Polygon |
triPoints(java.awt.Rectangle rect,
Direction orientation)
Returns the Polygon for a triangle in the middle of the provided
rect, pointing in the orientation
(given as angle from upwards, or orientation vector)
|
public static java.lang.Object choice(java.lang.Object[] elements, java.util.Random rnd)
public static int choice(int[] elements, java.util.Random rnd)
public static Direction choiceDir(java.util.ArrayList<Direction> elements, java.util.Random rnd)
public static java.lang.String formatString(java.lang.String str)
public static java.awt.Polygon triPoints(java.awt.Rectangle rect, Direction orientation)
rect
- rectangle with the locationorientation
- orientation of the sprite.public static java.awt.Polygon roundedPoints(java.awt.Rectangle rect)
public static Direction processMovementActionKeys(boolean[] key_pressed, int idx)
public static double normalise(double a_value, double a_min, double a_max)
public static double noise(double input, double epsilon, double random)
input
- value to be alteredepsilon
- relative amount the input will be alteredrandom
- random variable in range [0,1]public static boolean processUseKey(boolean[] key_pressed, int idx)
public static int argmax(double[] values)
public static java.lang.String toStringArray(java.lang.String[] array)
public static int findMaxDivisor(int value)
public static java.lang.String[][] readGames(java.lang.String filename)