robocode.control

Class RobocodeEngine


public class RobocodeEngine
extends Object

The RobocodeEngine is the old interface provided for external applications in order to let these applications run battles within the Robocode application, and to get the results from these battles. This class in the main class of the robocode.control package, and the reason for having this control package. The RobocodeEngine is used by RoboRumble@Home, which is integrated in Robocode, but also RoboLeague and RobocodeJGAP. In addition, the RobocodeEngine is also used by the test units for testing the Robocode application itself.
Authors:
Mathew A. Nelson (original)
Flemming N. Larsen (contributor)
Robert D. Maupin (contributor)
Nathaniel Troutman (contributor)

Constructor Summary

RobocodeEngine(File robocodeHome, RobocodeListener listener)
Creates a new RobocodeEngine for controlling Robocode.
RobocodeEngine(RobocodeListener listener)
Creates a new RobocodeEngine for controlling Robocode.

Method Summary

void
abortCurrentBattle()
Aborts the current battle if it is running.
void
close()
Closes the RobocodeEngine and releases any allocated resources.
RobotSpecification[]
getLocalRepository()
Returns all robots available from the local robot repository of Robocode.
String
getVersion()
Returns the installed version of Robocode.
void
runBattle(BattleSpecification battleSpecification)
Runs the specified battle.
void
setVisible(boolean visible)
Shows or hides the Robocode window.
protected @Override
void finalize()

Constructor Details

RobocodeEngine

public RobocodeEngine(File robocodeHome,
                      RobocodeListener listener)
Creates a new RobocodeEngine for controlling Robocode.
Parameters:
robocodeHome - the root directory of Robocode, e.g. C:\Robocode.
listener - the listener that must receive the callbacks from this RobocodeEngine.

RobocodeEngine

public RobocodeEngine(RobocodeListener listener)
Creates a new RobocodeEngine for controlling Robocode. The JAR file of Robocode is used to determine the root directory of Robocode. See RobocodeEngine(File,RobocodeListener).
Parameters:
listener - the listener that must receive the callbacks from this RobocodeEngine.

Method Details

abortCurrentBattle

public void abortCurrentBattle()
Aborts the current battle if it is running.

close

public void close()
Closes the RobocodeEngine and releases any allocated resources. You should call this when you have finished using the RobocodeEngine. This method automatically disposes the Robocode window if it open.

getLocalRepository

public RobotSpecification[] getLocalRepository()
Returns all robots available from the local robot repository of Robocode. These robots must exists in the /robocode/robots directory, and must be compiled in advance.
Returns:
an array of all available robots from the local robot repository.

getVersion

public String getVersion()
Returns the installed version of Robocode.
Returns:
the installed version of Robocode.

runBattle

public void runBattle(BattleSpecification battleSpecification)
Runs the specified battle.
Parameters:
battleSpecification - the specification of the battle to play including the participation robots.

setVisible

public void setVisible(boolean visible)
Shows or hides the Robocode window.
Parameters:
visible - true if the Robocode window must be set visible; false otherwise.

void finalize

protected @Override void finalize()
            throws Throwable