|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectrc.yoda.utils.YUtils
public final class YUtils
YUtils - A utilies class that contains common variables and methods needed throughout this robot
| Field Summary | |
|---|---|
static java.awt.geom.Rectangle2D.Double |
battleField
A rectangle the size of the current safe battle field, the border the size of WALL_MARGIN is removed |
static double |
battleFieldHeight
The pixel height of the current battle field, defaults to 600 |
static double |
battleFieldWidth
The pixel width of the current battle field, defaults to 800 |
static int |
BOT_WIDTH
The pixel width of a robocode robot |
static java.awt.geom.Rectangle2D.Double |
field
A rectangle the size of the current battle field |
static int |
WALL_MARGIN
The closest distance a robot can be from a wall with out hitting it |
static int |
WALL_STICK
The distance ahead of the robot to start wall smoothing |
| Constructor Summary | |
|---|---|
YUtils()
|
|
| Method Summary | |
|---|---|
static double |
absoluteBearing(java.awt.geom.Point2D.Double source,
java.awt.geom.Point2D.Double target)
Caculates the absolute bearing relative from source to the target |
static int |
backAsFrontDirection(double newHeading,
double oldHeading)
Calculates direction to move based on your oldheading and your wanted heading |
static double |
backAsFrontTurn(double newHeading,
double oldHeading)
Calculates how to move based on your oldheading and the heading you want |
static double |
cosineLaw(double a,
double b,
double c)
Calculates the angle opposite side a using the cosine Law |
static double |
getMinBulletPower(double damage)
|
static double |
limit(double minimum,
double value,
double maximum)
Caps a value to within a minimum and maximum range |
static double |
maxEscapeAngle(double velocity)
Calculates the max angle a robot can travel going max velocity if firing a bullet travel a specified velocity |
static double |
normalAbsoluteAngle(double angle)
Normalizes an angle to an absolute angle. |
static double |
normalRelativeAngle(double angle)
Normalizes an angle to a relative angle. |
static java.awt.geom.Point2D.Double |
project(java.awt.geom.Point2D.Double location,
double angle,
double distance)
Projects a location a certain distance along its current angle |
static double |
rollingAverage(double currentAvg,
double newEntry,
double depth,
double weighting)
Calculates a rolling average of a current average and a new entry using the data current depth and this entry's weighting |
static void |
setFieldAttr(robocode.AdvancedRobot robot)
Extracts battle field specifications from an AdvancedRobot class |
static int |
sign(double v)
Calculates the sign(+/-) of an number |
static double |
stopDistance(double velocity)
Caculates the distance traveled while stopping from a specified velocity |
static double |
wallSmoothing(java.awt.geom.Point2D.Double botLocation,
double angle,
int orientation)
Caculates a "wallsmoothed" angle for a point traveling along a specified angle and a left or right orientation |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int BOT_WIDTH
public static final int WALL_STICK
public static final int WALL_MARGIN
public static double battleFieldWidth
public static double battleFieldHeight
public static java.awt.geom.Rectangle2D.Double field
public static java.awt.geom.Rectangle2D.Double battleField
| Constructor Detail |
|---|
public YUtils()
| Method Detail |
|---|
public static void setFieldAttr(robocode.AdvancedRobot robot)
an - AdvancedRobotpublic static int sign(double v)
a - number
public static double maxEscapeAngle(double velocity)
bullet - velocity
public static double limit(double minimum,
double value,
double maximum)
minimum - value of rangevalue - to capmaximum - value of range
public static double stopDistance(double velocity)
velocity - at which appling breaks
public static double backAsFrontTurn(double newHeading,
double oldHeading)
wanted - headingheading - current at
public static int backAsFrontDirection(double newHeading,
double oldHeading)
wanted - headingheading - current at
public static double cosineLaw(double a,
double b,
double c)
length - of side alength - of side blength - of side c
public static double rollingAverage(double currentAvg,
double newEntry,
double depth,
double weighting)
current - average of samplenew - entry to averagedepth - of the sampleweighting - for this entry
public static double absoluteBearing(java.awt.geom.Point2D.Double source,
java.awt.geom.Point2D.Double target)
source - fo bearingtarget - of the bearingabsolute - bearing from source to targetpublic static double normalAbsoluteAngle(double angle)
angle - the angle to normalize
public static double normalRelativeAngle(double angle)
angle - the angle to normalize
public static java.awt.geom.Point2D.Double project(java.awt.geom.Point2D.Double location,
double angle,
double distance)
location - of the point to projectangle - point is traveldistance - to project the point
public static double getMinBulletPower(double damage)
public static double wallSmoothing(java.awt.geom.Point2D.Double botLocation,
double angle,
int orientation)
point - to wallsmooth froangle - to project pointorientation - of the robot (-1 / 1)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||