@@ -0,0 +1,2913 @@
+package raw;%0A%0Aimport static org.junit.Assert.assertTrue;%0Aimport robocode.BattleResults;%0Aimport robocode.control.events.BattleCompletedEvent;%0Aimport robocode.control.events.BattleMessageEvent;%0Aimport robocode.control.testing.RobotTestBed;%0A/**%0A * Base class for testing robots to see if they can beat other robots.%0A * To test other robots extend this class an override the get enemy robot method.%0A * @author Robert Ward%0A *%0A */%0Apublic class TestBattleMultiOutcomes extends RobotTestBed %7B%0A  %0A  %0A  /**%0A   * Keep track of the number of messages. Print them if desired.%0A   *%0A   * @param event The BattleMessageEvent.%0A   */%0A  @Override%0A  public void onBattleMessage(BattleMessageEvent event) %7B%0A    //override the printout of each round%0A  %7D%0A%0A  %0A  %0A  /**%0A   * Specifies the robots that are to be matched up in this test case.%0A   * @return The comma-delimited list of robots in this match.%0A   */%0A  @Override%0A  public String getRobotNames() %7B%0A    return getEnemyRobot() + %22,%22 + getTestRobot();%0A  %7D%0A  /**%0A   * Override this method to change the robot to Run a test battle against.%0A   * @return the name of the robot to fight%0A   */%0A  public String getEnemyRobot() %7B%0A    return %22sample.Crazy,sample.Fire,sample.MyFirstJuniorRobot%22;%0A  %7D%0A  %0A  /**%0A   * The robot being tested.%0A   * Override to test a different robot.%0A   * @return the name of the robot to test%0A   */%0A  public String getTestRobot() %7B%0A    return %22raw.Zero%22;%0A  %7D%0A  %0A  %0A  %0A  /**%0A   * The actual test, which asserts that the test robot has won over 30%25 of the rounds.%0A   * @param event Details about the completed battle.%0A   */%0A  @Override%0A  public void onBattleCompleted(BattleCompletedEvent event) %7B%0A    %0A    // Return the results in order of getRobotNames.%0A    BattleResults%5B%5D battleResults = event.getIndexedResults();%0A    %0A    BattleResults testRobotResults =  battleResults%5B0%5D; %0A    %0A    %0A    for ( int index = 0; index %3C battleResults.length ; index++) %7B%0A      if ( battleResults%5Bindex%5D.getTeamLeaderName().equals(this.getTestRobot() + %22*%22) ) %7B%0A        testRobotResults = battleResults%5Bindex%5D;%0A        %0A      %7D%0A  %0A    %7D%0A               %0A    String robotName = testRobotResults.getTeamLeaderName();%0A    %0A    %0A    System.out.println(%22Wins for %22 + robotName + %22 versus many %22 + testRobotResults.getFirsts());%0A    // Check to make sure test robot won over 30%25 of the rounds.%0A    assertTrue(%22Wins %22 + testRobotResults.getFirsts() , testRobotResults.getFirsts() %3E 30  );%0A  %7D%0A  %0A  /**%0A   * This test runs for 100 rounds.%0A   * @return The number of rounds. %0A   */%0A  @Override%0A  public int getNumRounds() %7B%0A    return 100;%0A  %7D%0A  %0A  /**%0A   * Returns true if the battle should be deterministic and thus robots will always start%0A   * in the same position each time. %0A   * %0A   * Override to return false to support random initialization. %0A   * @return True if the battle will be deterministic.%0A   */%0A  @Override%0A  public boolean isDeterministic() %7B%0A    return false;%0A  %7D%0A  %0A%7D%0A

Add many robot combat test