public abstract class JRobot2012_FH extends Pilot
Pilot.DropperCommand, Pilot.LauncherAmmunition
memoryConsumption
Constructor and Description |
---|
JRobot2012_FH() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
actions()
Every time 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(Vector p1,
Vector p2)
Mit Hilfe dieser Funktion kann ein Bot eine Linie auf's Spielfeld
zeichnen.
|
BodyFactory |
getBodyFactory()
determines the favorite supplier this
Pilot is designed for. |
protected static double |
getEnergyConsumptionEngine() |
protected static double |
getEnergyConsumptionProjectile() |
protected static double |
getEnergyConsumptionScanner() |
protected static double |
getEnergyProductionPerFrame() |
protected static int |
getFramesPerSecond() |
protected Scan |
getLastScan()
Liefert das Ergebnis des letzten "Scanblitzes".
|
protected static double |
getMaxArenaDiameter()
Zwei Panzer können sich nicht weiter als den zurückgegebenen
Wert voneinander entfernen.
|
protected static double |
getMaxBackwardVelocity() |
protected static double |
getMaxForwardVelocity() |
protected static Angle |
getMaxScanAperture()
Liefert den größtmöglichen Öffnungswinkel des
Scanners.
|
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()
Liefert die Geschwindigkeit (in Meter pro Sekunde), mit der das
Kanonenprojektil, das der Panzer verschiessen kann, fliegt.
|
protected Vector |
getVelocity()
Liefert den aktuellen Geschwindigkeitsvektor des Bots.
|
protected boolean |
isScanFromNow()
Liefert true, wenn der aktuelle Scanwert im Scanner von diesem Frame
stammt, also wenn gilt:
getTime() == getLastScan().timeOfScan Der Scanner hat also am Anfang dieses Frames einen Scan durchgeführt. |
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 |
setDebugText(java.lang.String text)
Übergibt dem Framework einen Text, den es direk unterhalb des
umherfahrenden Bots anzeigt.
|
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.
|
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.
The knowledge that 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:
Pilot.getTime()
, Pilot.getEnergy()
,
getEnergyProductionPerFrame()
getPosition()
, getOrientation()
,
getVelocity()
, getEnergyConsumptionEngine()
getLastScan()
, isScanFromNow()
,
getEnergyConsumptionScanner()
getProjectileSpeed()
,
getEnergyConsumptionProjectile()
A Pilot
is able to steer its Panzer
. Move
commands are obeyed by the Panzer until the Pilot canges its commands.
All other commands are comsumed when the Panzer tries to execute them.
Commands are issued by calling the following methods:
setAutopilot(Angle, double)
setScanDirection(Angle)
,
setScanAperture(Angle)
setLaunchProjectileCommand(Angle)
addDebugArrow(Vector, Vector)
,
addDebugCrosshair(Vector)
, addDebugLine(Vector, Vector)
setBodyColor(Color)
, setTurretColor(Color)
,
setNameColor(Color)
You may add fields as you like to your class to keep your state information through the run of the simulation.
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 use static fields, but that makes the framework's timeline
slider obsolete for debugging. So don't do it.
If you exceed a certain (very generous) threshold, the framework will
exert punishment upon your Pilot.
If your Pilot throws an Exception, there will also be some detriment.
In both cases, the framework will remove the existing Pilot instance and
put a new instance into the Panzer, so you may be able to carry on.
protected final void addDebugArrow(Vector start, Vector end)
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)
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(Vector p1, Vector p2)
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 Liniepublic 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 getEnergyConsumptionEngine()
protected static final double getEnergyConsumptionProjectile()
protected static final double getEnergyConsumptionScanner()
protected static final double getEnergyProductionPerFrame()
Hinweis: Nicht alles davon kann auch gespeichert werden.
protected static final int getFramesPerSecond()
protected final Scan getLastScan()
Hinweis: Der "letzte Scan" kann mehr als einen Simulationsschritt zurück liegen,
falls nicht in jedem Simulationsschritt ein Scanbefehl abgesetzt wird.
Überprüfen lässt sich dies mit Scan.timeOfScan
== Pilot.getTime()
.
Pilot.getLastScan()
protected static final double getMaxArenaDiameter()
protected static final double getMaxBackwardVelocity()
protected static final double getMaxForwardVelocity()
protected static final Angle getMaxScanAperture()
protected final Angle getOrientation()
protected final Vector getPosition()
protected static final double getProjectileSpeed()
protected final Vector getVelocity()
protected final boolean isScanFromNow()
protected final void setAutopilot(Angle direction, double speed)
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)
protected final void setDebugText(java.lang.String text)
text
- anzuzeigender Textprotected final void setLaunchProjectileCommand(Angle command)
protected final void setNameColor(java.awt.Color newNameColor)
protected final void setScanAperture(Angle aperture)
aperture
- Öffnungswinkelprotected final void setScanDirection(Angle scanDirection)
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)