public abstract class RobotTestBed<R extends IBasicRobot> extends BattleAdaptor
The user must set the system property robocode.home to the location of the robocode installation, otherwise we cannot set up the Robocode engine. If robocode.home is not a system property, we throw a RuntimeException.
Modifier and Type | Field and Description |
---|---|
protected BattlefieldSpecification |
battleFieldSpec
The battlefield specification, which is the default.
|
protected static IRobocodeEngine |
engine
The Robocode game engine instance used for this test.
|
protected robocode.control.RobotTestBed.EngineErrorsListener |
engineErrorsListener |
protected int |
errors
The number of errors generated during this battle so far.
|
protected StringBuilder |
errorText |
static boolean |
isDumpingErrors
True to specify that error messages should be printed out.
|
static boolean |
isDumpingMessages
True to specify that Robot messages should be printed out.
|
static boolean |
isDumpingOutput
True to specify that Robot output should be printed out.
|
static boolean |
isDumpingPositions
True to specify that the position during each turn should be printed out.
|
static boolean |
isDumpingTurns
True to specify that each turn should be printed out.
|
protected Throwable |
lastError |
protected static int |
messages
The number of messages generated during this battle so far.
|
protected R |
robotObject
Instance of tested robot
|
protected static String |
robotsPath |
protected robocode.control.RobotTestBed.TestErrorListener |
testErrorListener |
Constructor and Description |
---|
RobotTestBed() |
Modifier and Type | Method and Description |
---|---|
protected void |
after() |
protected void |
afterInit() |
protected void |
before()
The setup method run before each test, which sets up the listener on the engine for testing.
|
protected void |
beforeInit() |
String |
getEnemyName()
Must return a fully qualified enemy robot name to be in this battle.
|
protected int |
getExpectedErrors() |
int |
getExpectedRobotCount(String robotList)
Provides the number of robots in this battle.
|
String |
getInitialPositions()
Returns a comma or space separated list like: x1,y1,heading1, x2,y2,heading2, which are the
coordinates and heading of robot #1 and #2.
|
int |
getNumRounds()
Provides the number of rounds in this battle.
|
abstract String |
getRobotName()
Must return a fully qualified robot name to be in this battle.
|
boolean |
isDeterministic()
Defaults to true, indicating that the battle is deterministic and robots will always start
in the same position each time.
|
boolean |
isEnableRecording() |
boolean |
isEnableScreenshots() |
protected void |
run() |
protected void |
run(String enemyName) |
protected void |
run(String robotName,
String enemyName) |
protected void |
runBattle(String robotList,
int numRounds,
String initialPositions) |
protected void |
runSetup() |
protected void |
runTeardown() |
onBattleCompleted, onBattleError, onBattleFinished, onBattleMessage, onBattlePaused, onBattleResumed, onBattleStarted, onRoundEnded, onRoundStarted, onTurnEnded, onTurnStarted
protected static IRobocodeEngine engine
protected final BattlefieldSpecification battleFieldSpec
protected int errors
protected StringBuilder errorText
protected Throwable lastError
protected robocode.control.RobotTestBed.EngineErrorsListener engineErrorsListener
protected robocode.control.RobotTestBed.TestErrorListener testErrorListener
protected static int messages
protected static String robotsPath
public static boolean isDumpingPositions
public static boolean isDumpingTurns
public static boolean isDumpingOutput
public static boolean isDumpingErrors
public static boolean isDumpingMessages
protected R extends IBasicRobot robotObject
public abstract String getRobotName()
You must override this event to specify the robot to battle in this test case.
public String getEnemyName()
You must override this event to specify the robot to battle in this test case.
public int getNumRounds()
public String getInitialPositions()
Override this method to explicitly specify the initial positions.
Defaults to null, which means that the initial positions are determined randomly. Since battles are deterministic by default, the initial positions are randomly chosen but will always be the same each time you run the test case.
public int getExpectedRobotCount(String robotList)
robotList
- The list of robots.public boolean isDeterministic()
Override to support random initialization.
public boolean isEnableRecording()
public boolean isEnableScreenshots()
protected void beforeInit()
protected void afterInit()
protected void before()
protected void after()
protected void run(String enemyName)
protected void run()
protected int getExpectedErrors()
protected void runSetup()
protected void runTeardown()
Copyright © 2021 Robocode. All Rights Reserved.