public abstract class JRobot extends Pilot
Pilot
class to minimize
the necessary changes in the code of the old bots.
This is the compatibility interface for the ancients of the bots.
Pilot.DropperCommand, Pilot.LauncherAmmunition
memoryConsumption
Constructor and Description |
---|
JRobot() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
actions()
Everytime the simulation has progressed, each
Pilot may plan
the next actions. |
protected void |
addDebugArrow(Vector start,
Vector end)
Mit Hilfe dieser Funktion kann ein Bot einen Pfeil auf's Spielfeld
zeichnen.
|
protected void |
addDebugCrosshair(Vector position)
Mit Hilfe dieser Funktion kann ein Bot ein Kreuz auf's Spielfeld
zeichnen.
|
protected void |
addDebugLine(float x1,
float y1,
float x2,
float y2) |
protected void |
addDebugLine(Vector p1,
Vector p2)
Mit Hilfe dieser Funktion kann ein Bot eine Linie auf's Spielfeld
zeichnen.
|
protected Angle |
down()
Dieser Winkel hat den Wert 90° oder 1/2 Pi.
|
protected Vector |
getArenaSize() |
BodyFactory |
getBodyFactory()
determines the favorite supplier this
Pilot is designed for. |
protected double |
getLastScanResult() |
protected static double |
getMaxBackwardVelocity() |
protected static double |
getMaxForwardVelocity() |
protected static Angle |
getMaxScanAperture() |
protected Angle |
getOrientation()
Liefert die aktuelle Ausrichtung des Rumpfes.
Dieser Wert stimmt nicht immer genau mit dem Winkel des Geschwindigkeitsvektors überein, da der Bot auch seitlich rutschen kann (z.B. |
protected Vector |
getPosition()
Liefert die aktuelle absolute Position des JRobot in der Arena.
|
protected static double |
getProjectileSpeed() |
protected static double |
getReloadTime() |
protected static double |
getSafeShootDistance()
Deprecated.
|
protected double |
getTimeOfLastShot() |
protected Vector |
getVelocity()
Liefert den aktuellen Geschwindigkeitsvektor des Bots.
|
protected boolean |
hasBumped() |
protected boolean |
isScannerUpdated() |
protected Angle |
left()
Dieser Winkel hat den Wert 180° oder Pi.
|
protected Angle |
right()
Dieser Winkel hat den Wert 0° oder 0 Pi.
|
protected void |
setAutopilot(Angle direction,
double speed)
Diese Funktion aktiviert den Autopilot, welcher selbständig die
Geschwindigkeiten der beiden Panzerketten regelt.
Der Autopilot fährt so lange mit der angegebenen Geschwindigkeit in die angegebene Richtung, bis diese Funktion mit neuen Daten nochmals aufgerufen wird. |
protected void |
setBodyColor(java.awt.Color newColor)
Hiermit kann eine Farbe eingestellt werden, mit der das Bild des
Rumpfes gefiltert wird.
|
protected void |
setCannonCommand(Vector command) |
protected void |
setDebugArrow(Vector start,
Vector end) |
protected void |
setDebugCrosshairAbsolute(Vector position) |
protected void |
setDebugLines(Vector[] points)
Mit Hilfe dieser Funktion kann ein Bot mehrere Linien auf's Spielfeld
zeichnen.
|
protected void |
setDebugText(java.lang.String text)
übergibt dem Framework einen Text, den es direkt unterhalb des
umherfahrenden Bots anzeigt.
|
protected void |
setDropMineCommand(boolean isToBeLayed) |
protected void |
setLaunchProjectileCommand(Angle command) |
protected void |
setNameColor(java.awt.Color newNameColor)
Hiermit kann die Farbe des Schriftzuges verändert werden, der in der
Arena über dem Bot angezeigt wird.
|
protected void |
setScanAperture(Angle aperture)
Hiermit sagt man dem Scanner, mit welchem Öffnungswinkel der nüchste
"Scanblitz" erfolgen soll.
|
protected void |
setScanDirection(Angle scanDirection)
Setzt die Richtung, in die der nächste "Scanblitz" gehen soll.
|
protected void |
setTurretColor(java.awt.Color newColor)
Hiermit kann eine Farbe eingestellt werden, mit der das Bild des
Panzerturms gefiltert wird.
|
protected Angle |
up()
Dieser Winkel hat den Wert 270° oder 3/2 Pi.
|
getBodyColor, getCurrentTerrain, getEnergy, getHealth, getIsMovingInWrongDirection, getName, getNameColor, getPosOfBestBot, getTime, getTurretColor, init
clone
protected abstract void actions()
Pilot
may plan
the next actions. This is done through execution of this method.
Knowledge a Pilot
has of the momentary simulation state is
limited to what its Panzer
's sensors may display. Access to
the Panzer's sensor states is best done via the following methods:
getPosition
, getOrientation
,
getVelocity
, getTime
getLastScanResult
, isScanFromNow
,
isScannerUpdated
, getTimeOfLastScan
,
getScanInterval
getTimeOfLastShot
,
getProjectileSpeed
A Pilot
is able to steer its Panzer
. The Panzer
will follow those decisions until the Pilot canges its commands.
Decisions are made by calling the following routines:
setAutopilot
, setTrackspeedLeft
,
setTrackspeedRight
setScanDirection
, setScanAperture
setCannonCommand
setDebugText
, setDebugLines
You may add fields as you like to keep some state through the coarse of
the simulation run. But remember not to waste memory, as the framework
checks the size of your Pilot
's state and may refuse to
permit it to the arena.
You can always use static fields, but that makes the timeline
slider obsolete for debugging.
Also keep track of the computing time you spend, because if you exeed a
certain treshold, the framework may exert punishment upon your Pilot. If
you try to not waste time, there shouldn't be a problem, however.
If your Pilot causes an exception, there will also be some detriment, but
a new instance of your Pilot will be established, so you may be able to
carry on.
Package visibility. Pilots with a partial programming interface may want to have an invisible partial implementation of actions().
protected final void addDebugArrow(Vector start, Vector end)
Pilot
Alle Debug-Linien sind jeweils nur in dem Frame sichtbar, in dem sie hinzugefügt wurden. Für eine längere Anzeige müssen die Linien also in jedem Frame neu gesetzt werden.
protected final void addDebugCrosshair(Vector position)
Pilot
Alle Debug-Linien sind jeweils nur in dem Frame sichtbar, in dem sie hinzugefügt wurden. Für eine längere Anzeige müssen die Linien also in jedem Frame neu gesetzt werden.
position
- die Position des Kreuzesprotected final void addDebugLine(float x1, float y1, float x2, float y2)
protected final void addDebugLine(Vector p1, Vector p2)
Pilot
Alle Debug-Linien sind jeweils nur in dem Frame sichtbar, in dem sie hinzugefügt wurden. Für eine längere Anzeige müssen die Linien also in jedem Frame neu gesetzt werden.
p1
- Startpunkt der Liniep2
- Endpunkt der Linieprotected final Angle down()
protected final Vector getArenaSize()
public final BodyFactory getBodyFactory()
Pilot
Pilot
is designed for.
Implementor is obligated to add the final modifier.
getBodyFactory
in class Pilot
BodyFactory
protected final double getLastScanResult()
protected static final double getMaxBackwardVelocity()
protected static final double getMaxForwardVelocity()
protected static final Angle getMaxScanAperture()
protected final Angle getOrientation()
Pilot
protected final Vector getPosition()
Pilot
protected static final double getProjectileSpeed()
protected static final double getReloadTime()
@Deprecated protected static double getSafeShootDistance()
protected final double getTimeOfLastShot()
protected final Vector getVelocity()
Pilot
protected final boolean hasBumped()
protected final boolean isScannerUpdated()
protected final Angle left()
protected final Angle right()
protected final void setAutopilot(Angle direction, double speed)
Pilot
Hinweis: Der Bot kann vorwärts schneller als rückwärts fahren.
direction
- gewünschte Fahrtrichtung - in diese Richtung soll die Front zeigen.speed
- gewünschte Geschwindigkeit im Intervall [-1...+1].
Werte kleiner als Null fahren rückwärtsprotected final void setBodyColor(java.awt.Color newColor)
Pilot
protected final void setCannonCommand(Vector command)
protected final void setDebugCrosshairAbsolute(Vector position)
protected final void setDebugLines(Vector[] points)
Pilot
Alle Debug-Linien sind jeweils nur in dem Frame sichtbar, in dem sie hinzugefügt wurden. Für eine lüngere Anzeige müssen die Linien also in jedem Frame neu deklariert werden.
points
- Start- und Endpunkte der Linienprotected final void setDebugText(java.lang.String text)
Pilot
text
- anzuzeigender Textprotected final void setDropMineCommand(boolean isToBeLayed)
protected final void setLaunchProjectileCommand(Angle command)
protected final void setNameColor(java.awt.Color newNameColor)
Pilot
protected final void setScanAperture(Angle aperture)
Pilot
aperture
- Öffnungswinkelprotected final void setScanDirection(Angle scanDirection)
Pilot
Hinweis: Dieser Befehl setzt nur einen Scanblitz ab. Sobald dieser erfolgt ist muss der Auslöser erneut betätigt werden, um weiter zu scannen. So ist also ein Scanblitz pro Simulationszyklus möglich. Bei mehrmaligem Aufruf dieser Methode innerhalb eines Simulationszyklus gilt der letzte Aufruf.
Z.B. Scannen zum linken Bildschirmrand hin:
setScanDirection(new Angle(Math.PI, "radians"));
oder: setScanDirection(LEFT);
Der Radarstrahl wird in die Richtung der eingestellten Scanrichtung ausgesendet und erfasst den Gegner, wenn sich dieser maximal Öffnungswinkel/2 links oder Öffnungswinkel/2 rechts von dieser Richtung befindet.
scanDirection
- gewünschte Scanrichtungprotected final void setTurretColor(java.awt.Color newColor)
Pilot
protected final Angle up()