public class RobocodeEngine extends Object implements IRobocodeEngine
This class in the main entry class of the robocode.control package.
The RobocodeEngine is used by e.g. RoboRumble@Home client, which is integrated in Robocode. In addition, the RobocodeEngine is also used by the test units for testing the Robocode application itself.
| Constructor and Description |
|---|
RobocodeEngine()
Creates a new RobocodeEngine for controlling Robocode.
|
RobocodeEngine(File robocodeHome)
Creates a new RobocodeEngine for controlling Robocode.
|
RobocodeEngine(File robocodeHome,
RobocodeListener listener)
Deprecated.
Since 1.6.2. Use
RobocodeEngine(File) and
addBattleListener() instead.
Creates a new RobocodeEngine for controlling Robocode. |
RobocodeEngine(IBattleListener listener) |
RobocodeEngine(RobocodeListener listener)
Deprecated.
Since 1.6.2. Use
RobocodeEngine() and
addBattleListener() instead.
Creates a new RobocodeEngine for controlling Robocode. The JAR file of Robocode is used to determine the root directory of Robocode. |
| Modifier and Type | Method and Description |
|---|---|
void |
abortCurrentBattle()
Aborts the current battle if it is running and waits for the end.
|
void |
abortCurrentBattle(boolean waitTillEnd)
Aborts the current battle if it is running.
|
void |
addBattleListener(IBattleListener listener)
Adds a battle listener that must receive events occurring in battles.
|
void |
close()
Closes the RobocodeEngine and releases any allocated resources it holds.
|
protected void |
finalize() |
static File |
getCurrentWorkingDir()
Returns the current working directory.
|
RobotSpecification[] |
getLocalRepository()
Returns all robots available from the local robot repository of Robocode.
|
RobotSpecification[] |
getLocalRepository(String selectedRobots)
Returns a selection of robots available from the local robot repository
of Robocode.
|
static File |
getRobotsDir()
Returns the directory containing the robots.
|
String |
getVersion()
Returns the installed version of Robocode controlled by this RobocodeEngine.
|
static void |
printRunningThreads()
Prints out all running threads to standard system out.
|
void |
removeBattleListener(IBattleListener listener)
Removes a battle listener that has previously been added to this object.
|
void |
runBattle(BattleSpecification battleSpecification)
Runs the specified battle.
|
void |
runBattle(BattleSpecification battleSpecification,
boolean waitTillOver)
Runs the specified battle.
|
void |
runBattle(BattleSpecification battleSpecification,
String initialPositions,
boolean waitTillOver)
Runs the specified battle.
|
void |
runBattle(BattleSpecification battleSpecification,
String initialPositions,
boolean waitTillOver,
boolean enableRecording) |
static void |
setLogErrorsEnabled(boolean enable)
Enables or disables errors logged to
System.err. |
static void |
setLogMessagesEnabled(boolean enable)
Enables or disables messages and warnings logged to
System.out. |
void |
setVisible(boolean visible)
Shows or hides the Robocode window.
|
void |
takeScreenshot()
Saves screenshot to disk, if the UI is initialized
|
void |
waitTillBattleOver()
Will block caller until current battle is over.
|
public RobocodeEngine()
RobocodeEngine(File),
close()public RobocodeEngine(File robocodeHome)
robocodeHome - the home directory of Robocode, e.g. C:\Robocode.RobocodeEngine(),
close()@Deprecated public RobocodeEngine(File robocodeHome, RobocodeListener listener)
RobocodeEngine(File) and
addBattleListener() instead.
Creates a new RobocodeEngine for controlling Robocode.
robocodeHome - the root directory of Robocode, e.g. C:\Robocode.listener - the listener that must receive the callbacks from this
RobocodeEngine.RobocodeEngine(),
RobocodeEngine(File),
close()@Deprecated public RobocodeEngine(RobocodeListener listener)
RobocodeEngine() and
addBattleListener() instead.
Creates a new RobocodeEngine for controlling Robocode. The JAR file of Robocode is used to determine the root directory of Robocode.
listener - the listener that must receive the callbacks from this
RobocodeEngine.RobocodeEngine(),
RobocodeEngine(File),
close()public RobocodeEngine(IBattleListener listener)
protected void finalize()
throws Throwable
public void addBattleListener(IBattleListener listener)
addBattleListener in interface IRobocodeEnginelistener - the battle listener that must retrieve the event from
the battles.IRobocodeEngine.removeBattleListener(robocode.control.events.IBattleListener)public void removeBattleListener(IBattleListener listener)
removeBattleListener in interface IRobocodeEnginelistener - the battle listener that must be removed.IRobocodeEngine.addBattleListener(robocode.control.events.IBattleListener)public void close()
close in interface IRobocodeEnginepublic String getVersion()
getVersion in interface IRobocodeEnginepublic static File getCurrentWorkingDir()
public static File getRobotsDir()
public void setVisible(boolean visible)
setVisible in interface IRobocodeEnginevisible - true if the Robocode window must be set visible;
false otherwise.public RobotSpecification[] getLocalRepository()
getLocalRepository in interface IRobocodeEngineRobotSpecification,
IRobocodeEngine.getLocalRepository(String)public RobotSpecification[] getLocalRepository(String selectedRobots)
Notice: If a specified robot cannot be found in the repository, it will not be returned in the array of robots returned by this method.
getLocalRepository in interface IRobocodeEngineselectedRobots - a comma or space separated list of robots to
return. The full class name must be used for
specifying the individual robot, e.g.
"sample.Corners, sample.Crazy".selectedRobotList parameter.RobotSpecification,
IRobocodeEngine.getLocalRepository()public void runBattle(BattleSpecification battleSpecification)
runBattle in interface IRobocodeEnginebattleSpecification - the specification of the battle to run including the
participation robots.IRobocodeEngine.runBattle(robocode.control.BattleSpecification, boolean),
BattleSpecification,
IRobocodeEngine.getLocalRepository()public void runBattle(BattleSpecification battleSpecification, boolean waitTillOver)
runBattle in interface IRobocodeEnginebattleSpecification - the specification of the battle to run including the
participating robots.waitTillOver - will block caller till end of battle if setIRobocodeEngine.runBattle(robocode.control.BattleSpecification),
BattleSpecification,
IRobocodeEngine.getLocalRepository()public void runBattle(BattleSpecification battleSpecification, String initialPositions, boolean waitTillOver)
runBattle in interface IRobocodeEnginebattleSpecification - the specification of the battle to run including the
participating robots.initialPositions - a comma or space separated list like: x1,y1,heading1,
x2,y2,heading2, which are the coordinates and heading of robot #1 and #2.
So e.g. 0,0,180, 50,80,270 means that robot #1 has position (0,0) and
heading 180, and robot #2 has position (50,80) and heading 270.waitTillOver - will block caller till end of battle if setIRobocodeEngine.runBattle(BattleSpecification),
BattleSpecification,
IRobocodeEngine.getLocalRepository()public void runBattle(BattleSpecification battleSpecification, String initialPositions, boolean waitTillOver, boolean enableRecording)
runBattle in interface IRobocodeEnginepublic void waitTillBattleOver()
public void abortCurrentBattle()
abortCurrentBattle in interface IRobocodeEngineIRobocodeEngine.runBattle(robocode.control.BattleSpecification)public void abortCurrentBattle(boolean waitTillEnd)
abortCurrentBattle in interface IRobocodeEnginewaitTillEnd - will block caller until the battle is overIRobocodeEngine.runBattle(robocode.control.BattleSpecification)public void takeScreenshot()
takeScreenshot in interface IRobocodeEnginepublic static void printRunningThreads()
public static void setLogMessagesEnabled(boolean enable)
System.out.enable - true if log messages must be enabled; false if log messages must be disabled.setLogErrorsEnabled(boolean)public static void setLogErrorsEnabled(boolean enable)
System.err.enable - true if log errors must be enabled; false if log errors must be disabled.setLogMessagesEnabled(boolean)Copyright © 2021 Robocode. All Rights Reserved.