public abstract class JRobot2015 extends Pilot
The class offers methods for communication with the framework (sensors and actuators).
To be able to participate in the competition, inheritance from this specific class is obligatory. JRobots extending different classes cannot participate.
actions()
,
Serialized FormPilot.DropperCommand, Pilot.LauncherAmmunition
memoryConsumption
Constructor and Description |
---|
JRobot2015() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
actions()
At every simulation cycle every JRobot plans its next actions.
|
protected void |
addDebugArrow(Vector start,
Vector end)
Using this method, you can paint lines onto the arena.
|
protected void |
addDebugCrosshair(Vector position)
Using this method, you can paint a mark onto the arena.
|
protected void |
addDebugLine(Vector p1,
Vector p2)
Using this method, you can paint lines onto the arena.
|
BodyFactory |
getBodyFactory()
determines the favorite supplier this
Pilot is designed for. |
protected static double |
getEnergyConsumptionBooster()
The booster needs a lot more energy than the tractors.
|
protected static double |
getEnergyConsumptionEngine() |
protected static double |
getEnergyConsumptionGrenade() |
protected static double |
getEnergyConsumptionSonarForMeterStdDev()
The more energy, the more exact a sonar result will be.
|
protected static double |
getEnergyProductionPerFrame()
The JRobot aquires a small amount of energy in every simulation cycle.
|
protected static int |
getFramesPerSecond()
The physical duration of each simulated frame is constant
(whereas the duration in real time may vary).
|
protected static double |
getGrenadeDamageMax()
The maximum damage is inflicted upon a direct hit
- either by the grenade or by stepping on a deployed mine.
|
protected static double |
getGrenadeDamageRadius()
The mine does damage in a medium range.
|
protected static double |
getGrenadeSpeed()
The speed of of a grenade is constant and not influenced by the movement of the
JRobot it originates from.
|
protected static double |
getGrenadeTriggerRadius()
A deployed mine triggers its detonation at this given radius.
|
protected static double |
getJRobotLength()
With this value you can estimate distances in the arena visually.
|
protected SonarTrace |
getLastSonarTrace()
Retrieves the latest value of the echolocation device.
|
protected static double |
getMaxArenaDiameter()
Two tanks cannot move farther away from each other than this given distance.
|
protected static double |
getMaxBackwardVelocity()
The maximum speed is reached by accelerating infinitely at one given direction.
|
protected static double |
getMaxForwardVelocity()
The maximum speed is reached by accelerating infinitely at one given direction.
|
protected Angle |
getOrientation()
Retrieves the current orientation of this tank's body.
|
protected Vector |
getPosition()
Retrieves the current absolute position of this JRobot.
|
protected ProximityScan |
getProximityScan()
Other than the radar scanner the proximity scanners are aware of flying or lying small objects
- in short: projectiles and droppables.
|
protected static double |
getProximityScannerGroundRange() |
protected static double |
getProximityScannerProjectileRange() |
protected Vector |
getVelocity()
Retrieves this JRobots current absolute velocity.
|
protected void |
setAutopilot(Angle direction,
double speed)
This routine sets the built in 'autopilot' to drive in the given direction with given speed.
|
protected void |
setBodyColor(java.awt.Color newColor)
Changes the painting of the tank's body.
|
protected void |
setBoost()
Fires a mighty booster which lets the tank jump forward.
|
protected void |
setLaunchProjectileCommand(Angle command,
double range)
This is the 'launch' button to fire grenades.
|
protected void |
setNameColor(java.awt.Color newNameColor)
Changes the color of the writing which draws this pilot's name.
|
protected void |
setSonarEnergy(double energy)
Sets an amount of energy for the sonar scanner.
|
protected void |
setTurretColor(java.awt.Color newColor)
Changes the painting of the tank's turret.
|
getBodyColor, getCurrentTerrain, getEnergy, getHealth, getIsMovingInWrongDirection, getName, getNameColor, getPosOfBestBot, getTime, getTurretColor, init
clone
protected abstract void actions()
Every JRobot has only limited knowledge of its surroundings. That limit is set by its sensors. Sensors in general are methods starting with get...:
Pilot.getTime()
, Pilot.getEnergy()
,
getEnergyProductionPerFrame()
getPosition()
, getOrientation()
,
getVelocity()
, getEnergyConsumptionEngine()
,
Pilot.getLastScan()
, #isScanFromNow()
, Pilot.getScanAperture()
,
getProximityScan()
getProximityScannerProjectileRange()
, getProximityScannerGroundRange()
getEnergyConsumptionSonarForMeterStdDev()
getGrenadeSpeed()
,
getEnergyConsumptionGrenade()
The JRobot is called for actions, which are will have effect in the next simulation cycle. Issued actions in general are methods starting with set...:
setSonarEnergy(double)
,
setLaunchProjectileCommand(Angle, double)
setAutopilot(Angle, double)
,
setBoost()
addDebugArrow(Vector, Vector)
,
addDebugCrosshair(Vector)
, addDebugLine(Vector, Vector)
setBodyColor(Color)
, setTurretColor(Color)
,
setNameColor(Color)
In package jrobots.utils there are several helper classes to be used as necessary.
You may want to add fields to your JRobot class.
While it is possible to use static fields, these are not affected by the timeline slider in the GUI, which makes debugging less practical. Please don't use static fields while you can avoid it.
Runtime and memory are watched by the framework. If a reasonable use of the framework is confined by
your programming, the responsible JRobot may be expelled from the competition.
Exceptions will be caught by the framework and the JRobot will be restarted.
Please be aware of exceptions on the console, as the robot loses its memory at every restart.
protected final void addDebugArrow(Vector start, Vector end)
Use this to visualize your data. This is a kind of visual logging and can be quite helpful for debugging.
The mark will be painted for only one frame. If you want it to last, paint again every frame.
p1
- - starting point of the linep2
- - ending point of the line; this is where the arrow points toprotected final void addDebugCrosshair(Vector position)
Use this to visualize your data. This is a kind of visual logging and can be quite helpful for debugging.
The mark will be painted for only one frame. If you want it to last, paint again every frame.
p1
- - absolute position of the painted crosshairprotected final void addDebugLine(Vector p1, Vector p2)
Use this to visualize your data. This is a kind of visual logging and can be quite helpful for debugging.
The mark will be painted for only one frame. If you want it to last, paint again every frame.
p1
- - starting point of the linep2
- - ending point of the linepublic final BodyFactory getBodyFactory()
Pilot
Pilot
is designed for.
Implementor is obligated to add the final modifier.
getBodyFactory
in class Pilot
BodyFactory
protected static final double getEnergyConsumptionBooster()
protected static final double getEnergyConsumptionEngine()
protected static final double getEnergyConsumptionGrenade()
protected static final double getEnergyConsumptionSonarForMeterStdDev()
protected static final double getEnergyProductionPerFrame()
protected static final int getFramesPerSecond()
This value is helpful if you want to know the amount of time passed between two calls of actions().
protected static final double getGrenadeDamageMax()
protected static final double getGrenadeDamageRadius()
protected static final double getGrenadeSpeed()
protected static final double getGrenadeTriggerRadius()
protected static final double getJRobotLength()
protected final SonarTrace getLastSonarTrace()
To be able to retrieve a sonar trace, the device must have been powered by setSonarEnergy() at a prior time.
Note: The value is not consumed by the call. To select only the current value make sure that
getLastSonarTrace().timestamp == getTime() holds.
Pilot.getLastSonarTrace()
protected static final double getMaxArenaDiameter()
protected static final double getMaxBackwardVelocity()
protected static final double getMaxForwardVelocity()
protected final Angle getOrientation()
protected final Vector getPosition()
protected final ProximityScan getProximityScan()
Reveals the position of the nearest projectile/droppable or null if there is no such object in range of the proximity scanner.
Own grenades are not spotted by the proximity scanner until they are deployed and readied.
The usage of the proximity scanner does not consume energy.
protected static final double getProximityScannerGroundRange()
#getProximityScan()}
protected static final double getProximityScannerProjectileRange()
#getProximityScan()}
protected final Vector getVelocity()
protected final void setAutopilot(Angle direction, double speed)
The tractor speeds will be automatically set so that the tank's bow will point to that direction eventually.
The autopilot will be executed until a different command tells otherwise.
The tractors drain energy when moving. The higher the set speed the more.
The backward speed is slower than the speed forward.
direction
- - direction to point the bow tospeed
- - [-1;+1] values greater than zero drive forward; values less than zero drive backward.protected final void setBodyColor(java.awt.Color newColor)
As the metal already has a color, applying a white color will not result in a white paint.
protected final void setBoost()
This consumes more energy than moving there by the tractors, but it can even be used to dodge grenades.
Once executed, the booster burns for some simulation cycles before it ceases.
protected final void setLaunchProjectileCommand(Angle command, double range)
It sets the direction to fire at and a range at which the grenade will detonate/deploy.
You can launch one projectile per frame at maximum. If there is already a launch command which was not executed yet, that command will be overwritten.
This command issues only one fire command. As soon at the cannon is available, it will be executed. To fire a second shot, wait for the first shot to be executed, then set the second command.
Note that firing projectiles costs energy. The command will not be executed if there is not enough energy.
command
- - direction to fire atrange
- - distance to detonatePilot#setLaunchProjectileCommand(Angle)
protected final void setNameColor(java.awt.Color newNameColor)
protected final void setSonarEnergy(double energy)
On your JRobot is mounted a passive echolocation device.
If powered, it delivers one SonarTrace value per frame.
The trace is not exact. The trace is of higher quality the more energy is spent.
The set value is consumed at each simulation step. To constantly receive new sonar traces, the setter has to be called at each frame.
energy
- - amount of energy to be spent for the sonar device at the next simulation steputils#SonarTrace
protected final void setTurretColor(java.awt.Color newColor)
As the metal already has a color, applying a white color will not result in a white paint.