Package robocode.control.snapshot

Examples of robocode.control.snapshot.IRobotSnapshot


  }

  @Override
  public void onTurnEnded(TurnEndedEvent event) {
    super.onTurnEnded(event);
    IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1];
    final String streamSnapshot = robot.getOutputStreamSnapshot();

    if (streamSnapshot.contains("Death!")) {
      lost++;
    }
    if (streamSnapshot.contains("BattleEnded!")) {
View Full Code Here


  }

  @Override
  public void onTurnEnded(TurnEndedEvent event) {
    super.onTurnEnded(event);
    IRobotSnapshot bp = event.getTurnSnapshot().getRobots()[1];

    final int time = event.getTurnSnapshot().getTurn();

    switch (time) {
    case 30:
View Full Code Here

  }

  @Override
  public void onTurnEnded(TurnEndedEvent event) {
    super.onTurnEnded(event);
    IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1];
    final String streamSnapshot = robot.getOutputStreamSnapshot();

    if (streamSnapshot.contains("Death!")) {
      lost++;
    }
    if (streamSnapshot.contains("BattleEnded!")) {
View Full Code Here

  @Override
  public void onTurnEnded(TurnEndedEvent event) {
    super.onTurnEnded(event);

    Assert.assertTrue(event.getTurnSnapshot().getTurn() <= 1407);
    IRobotSnapshot fire = event.getTurnSnapshot().getRobots()[0];
    IRobotSnapshot random = event.getTurnSnapshot().getRobots()[1];

    if (event.getTurnSnapshot().getTurn() == 1241) {
      Assert.assertNear(213.18621928, fire.getX());
      Assert.assertNear(371.45706118, fire.getY());
      Assert.assertNear(782.0, random.getX());
      Assert.assertNear(230.95479253, random.getY());
    }
  }
View Full Code Here

    return "tested.robotscs.WatchBullets,SampleCs.SittingDuck";
  }

  public void onTurnEnded(TurnEndedEvent event) {
    super.onTurnEnded(event);
    final IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[0];

    final String out = robot.getOutputStreamSnapshot();
    final int time = event.getTurnSnapshot().getTurn();

    test(out, time, 33, "33 487.43878 119.51132 347.66745 True");
    test(out, time, 45, "45 459.24551 248.46534 347.66745 True");
    test(out, time, 52, "52 442.79943 323.68851 347.66745 True");
View Full Code Here

  @Override
  public void onRoundStarted(final RoundStartedEvent event) {
    super.onRoundStarted(event);
    if (event.getRound() == 0) {
      IRobotSnapshot crazy = event.getStartSnapshot().getRobots()[0];
      IRobotSnapshot target = event.getStartSnapshot().getRobots()[1];

      Assert.assertNear(568.1445492, crazy.getX());
      Assert.assertNear(163.0032275, crazy.getY());
      Assert.assertNear(436.7181397, target.getX());
      Assert.assertNear(351.5039067, target.getY());
    }
  }
View Full Code Here

  @Override
  public void onTurnEnded(TurnEndedEvent event) {
    super.onTurnEnded(event);
    lastTurn = event.getTurnSnapshot().getTurn();

    IRobotSnapshot crazy = event.getTurnSnapshot().getRobots()[0];
    IRobotSnapshot target = event.getTurnSnapshot().getRobots()[1];

    if (lastTurn == 1) {
      Assert.assertNear(567.2831835, crazy.getX());
      Assert.assertNear(162.4952421, crazy.getY());
      Assert.assertNear(436.7181397, target.getX());
      Assert.assertNear(351.5039067, target.getY());
    }

    if (lastTurn == 1700) {
      Assert.assertNear(373.9958377, crazy.getX());
      Assert.assertNear(196.1380677, crazy.getY());
      Assert.assertNear(340.3212984, target.getX());
      Assert.assertNear(456.5502002, target.getY());
    }
  }
View Full Code Here

  }

  @Override
  public void onRoundStarted(final RoundStartedEvent event) {
    super.onRoundStarted(event);
    IRobotSnapshot rate = event.getStartSnapshot().getRobots()[0];

    originalHeading = rate.getBodyHeading();
    originalX = rate.getX();
  }
View Full Code Here

  @Override
  public void onTurnEnded(TurnEndedEvent event) {
    super.onTurnEnded(event);
    turnNumber = event.getTurnSnapshot().getTurn();
   
    IRobotSnapshot rate = event.getTurnSnapshot().getRobots()[0];
   
    // Test turnRate
    if (turnNumber == 10) {
      Assert.assertNear(Math.PI / 4, normalRelativeAngle(rate.getBodyHeading() - originalHeading));
    }
    if (turnNumber == 20) {
      Assert.assertNear(-Math.PI / 4, normalRelativeAngle(rate.getBodyHeading() - originalHeading));
    }
    if (turnNumber == 25) {
      // Test that turnRate was set to zero
      Assert.assertNear(-Math.PI / 4, normalRelativeAngle(rate.getBodyHeading() - originalHeading));
     
      // Test velocityRate
      double theta = rate.getBodyHeading();
      double deltaX = rate.getX() - originalX;
      double distanceTravelled = deltaX / Math.sin(theta);

      Assert.assertNear(9, distanceTravelled);
    }
    if (turnNumber == 35) {
      double theta = rate.getBodyHeading();
      double deltaX = rate.getX() - originalX;
      double distanceTravelled = deltaX / Math.sin(theta);

      Assert.assertNear(-35, distanceTravelled);
      originalGunHeading = rate.getGunHeading();
    }
    if (turnNumber == 45) {
      // Test that velocityRate was set to zero
      double theta = rate.getBodyHeading();
      double deltaX = rate.getX() - originalX;
      double distanceTravelled = deltaX / Math.sin(theta);

      Assert.assertNear(-47, distanceTravelled);

      // test gunRotationRate
      Assert.assertNear(Math.PI / 2, normalRelativeAngle(rate.getGunHeading() - originalGunHeading));
    }
    if (turnNumber == 55) {
      Assert.assertNear(Math.PI / 4, normalRelativeAngle(rate.getGunHeading() - originalGunHeading));
      originalRadarHeading = rate.getRadarHeading();
    }
   
    if (turnNumber == 65) {
      // test that gunRotationRate was set to zero
      Assert.assertNear(Math.PI / 4, normalRelativeAngle(rate.getGunHeading() - originalGunHeading))

      // test radarRotationRate
      Assert.assertNear(Math.PI / 2, normalRelativeAngle(rate.getRadarHeading() - originalRadarHeading));
    }
    if (turnNumber == 75) {
      Assert.assertNear(Math.PI / 4, normalRelativeAngle(rate.getRadarHeading() - originalRadarHeading));
    }
    if (turnNumber == 76) {
      // test that radarRotationRate was set to zero
      Assert.assertNear(Math.PI / 4, normalRelativeAngle(rate.getRadarHeading() - originalRadarHeading));   
   
  }
View Full Code Here

  }

  @Override
  public void onTurnEnded(TurnEndedEvent event) {
    super.onTurnEnded(event);
    IRobotSnapshot caveat1 = event.getTurnSnapshot().getRobots()[0];
    IRobotSnapshot caveat2 = event.getTurnSnapshot().getRobots()[1];
    IRobotSnapshot caveat3 = event.getTurnSnapshot().getRobots()[2];

    switch (event.getTurnSnapshot().getTurn()) {
    case 1:
      resetStartPositions(event.getTurnSnapshot());

      Assert.assertNear(1, caveat1.getVelocity());
      Assert.assertNear(1, caveat2.getVelocity());
      Assert.assertNear(1, caveat3.getVelocity());

      Assert.assertNear(1 - 1, distance(0, caveat1));
      Assert.assertNear(1 - 1, distance(1, caveat2));
      Assert.assertNear(1 - 1, distance(2, caveat3));
      break;

    case 2:
      Assert.assertNear(2, caveat1.getVelocity());
      Assert.assertNear(2, caveat2.getVelocity());
      Assert.assertNear(2, caveat3.getVelocity());

      Assert.assertNear(3 - 1, distance(0, caveat1));
      Assert.assertNear(3 - 1, distance(1, caveat2));
      Assert.assertNear(3 - 1, distance(2, caveat3));
      break;

    case 3:
      Assert.assertNear(3, caveat1.getVelocity());
      Assert.assertNear(3, caveat2.getVelocity());
      Assert.assertNear(3, caveat3.getVelocity());

      Assert.assertNear(6 - 1, distance(0, caveat1));
      Assert.assertNear(6 - 1, distance(1, caveat2));
      Assert.assertNear(6 - 1, distance(2, caveat3));
      break;

    case 4:
      Assert.assertNear(4, caveat1.getVelocity());
      Assert.assertNear(4, caveat2.getVelocity());
      Assert.assertNear(4, caveat3.getVelocity());

      Assert.assertNear(10 - 1, distance(0, caveat1));
      Assert.assertNear(10 - 1, distance(1, caveat2));
      Assert.assertNear(10 - 1, distance(2, caveat3));
      break;

    case 5:
      Assert.assertNear(5, caveat1.getVelocity());
      Assert.assertNear(5, caveat2.getVelocity());
      Assert.assertNear(5, caveat3.getVelocity());

      Assert.assertNear(15 - 1, distance(0, caveat1));
      Assert.assertNear(15 - 1, distance(1, caveat2));
      Assert.assertNear(15 - 1, distance(2, caveat3));
      break;

    case 6:
      Assert.assertNear(6, caveat1.getVelocity());
      Assert.assertNear(6, caveat2.getVelocity());
      Assert.assertNear(6, caveat3.getVelocity());

      Assert.assertNear(21 - 1, distance(0, caveat1));
      Assert.assertNear(21 - 1, distance(1, caveat2));
      Assert.assertNear(21 - 1, distance(2, caveat3));
      break;

    case 7:
      Assert.assertNear(7, caveat1.getVelocity());
      Assert.assertNear(7, caveat2.getVelocity());
      Assert.assertNear(7, caveat3.getVelocity());

      Assert.assertNear(28 - 1, distance(0, caveat1));
      Assert.assertNear(28 - 1, distance(1, caveat2));
      Assert.assertNear(28 - 1, distance(2, caveat3));
      break;

    case 8:
      Assert.assertNear(8, caveat1.getVelocity());
      Assert.assertNear(8, caveat2.getVelocity());
      Assert.assertNear(8, caveat3.getVelocity());

      Assert.assertNear(36 - 1, distance(0, caveat1));
      Assert.assertNear(36 - 1, distance(1, caveat2));
      Assert.assertNear(36 - 1, distance(2, caveat3));

      resetStartPositions(event.getTurnSnapshot());
      break;

    case 9:
      Assert.assertNear(8, caveat1.getVelocity());
      Assert.assertNear(8, caveat2.getVelocity());

      Assert.assertNear(6, caveat3.getVelocity()); // Caveat 3 (max. speed is set to 6)

      Assert.assertNear(8, distance(0, caveat1));
      Assert.assertNear(8, distance(1, caveat2));

      resetStartPositions(event.getTurnSnapshot());
View Full Code Here

TOP

Related Classes of robocode.control.snapshot.IRobotSnapshot

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.