Package robocode.control.snapshot

Examples of robocode.control.snapshot.IScoreSnapshot


  /**
   * {@inheritDoc}
   */
  public int compareTo(Object obj) {
    if (obj instanceof IScoreSnapshot) {
      IScoreSnapshot scoreSnapshot = (IScoreSnapshot) obj;
     
      double myScore = getTotalScore() + getCurrentScore();
      double hisScore = scoreSnapshot.getTotalScore() + scoreSnapshot.getCurrentScore();

      if (myScore < hisScore) {
        return -1;
      }
      if (myScore > hisScore) {
View Full Code Here


    }
  }

  public Object getValueAt(int row, int col) {

    final IScoreSnapshot statistics = scoreSnapshotList[row];

    switch (col) {
    case 0:
      return getPlacementString(row + 1);

    case 1:
      return statistics.getName();

    case 2: {
      final double current = statistics.getCurrentScore();
      final double total = statistics.getTotalScore();

      return (int) (current + 0.5) + " / " + (int) (total + current + 0.5) + "  ("
          + (int) (current / currentSum * 100) + " / " + (int) ((total + current) / (totalSum + currentSum) * 100)
          + "%)";
    }

    case 3: {
      final double current = statistics.getCurrentSurvivalScore();
      final double total = statistics.getTotalSurvivalScore();

      return (int) (current + 0.5) + " / " + (int) (total + current + 0.5);
    }

    case 4:
      return (int) (statistics.getTotalLastSurvivorBonus() + 0.5);

    case 5: {
      final double current = statistics.getCurrentBulletDamageScore();
      final double total = statistics.getTotalBulletDamageScore();

      return (int) (current + 0.5) + " / " + (int) (total + current + 0.5);
    }

    case 6: {
      final double current = statistics.getCurrentBulletKillBonus();
      final double total = statistics.getTotalBulletKillBonus();

      return (int) (current + 0.5) + " / " + (int) (total + current + 0.5);
    }

    case 7: {
      final double current = statistics.getCurrentRammingDamageScore();
      final double total = statistics.getTotalRammingDamageScore();

      return (int) (current + 0.5) + " / " + (int) (total + current + 0.5);
    }

    case 8: {
      final double current = statistics.getCurrentRammingKillBonus();
      final double total = statistics.getTotalRammingKillBonus();

      return (int) (current + 0.5) + " / " + (int) (total + current + 0.5);
    }

    case 9:
      return "" + statistics.getTotalFirsts();

    case 10:
      return "" + statistics.getTotalSeconds();

    case 11:
      return "" + statistics.getTotalThirds();

    default:
      return "";
    }
  }
View Full Code Here

  }

  @Override
  public void onBattleFinished(BattleFinishedEvent event) {
    final IScoreSnapshot[] scores = lastTurnSnapshot.getSortedTeamScores();
    final IScoreSnapshot score1 = scores[0];
    final IScoreSnapshot score2 = scores[1];

    double minTotal = Math.min(score1.getTotalScore(), score2.getTotalScore());
    double maxTotal = Math.max(score1.getTotalScore(), score2.getTotalScore());

    Assert.assertTrue("The total scores should be almost the same", maxTotal / minTotal <= 1.05);

    double minFirsts = Math.min(score1.getTotalFirsts(), score2.getTotalFirsts());
    double maxFirsts = Math.max(score1.getTotalFirsts(), score2.getTotalFirsts());

    Assert.assertTrue("The total firsts should be almost the same", maxFirsts / minFirsts <= 1.05);
  }
View Full Code Here

  }

  @Override
  public void onBattleFinished(BattleFinishedEvent event) {
    final IScoreSnapshot[] scores = lastTurnSnapshot.getSortedTeamScores();
    final IScoreSnapshot score1 = scores[0];
    final IScoreSnapshot score2 = scores[1];

    // 1sts + 2nds = number of rounds, e.g. 4 + 6 = 10 (where 4 is 1st places, and 6 is 2nd places)
    Assert.assertThat("1st ranked robot's total 1st and 2nd places must be equal to the number of rounds",
        score1.getTotalFirsts() + score1.getTotalSeconds(), is(getNumRounds()));
    Assert.assertThat("2nd ranked robot's total 1st and 2nd places must be equal to the number of rounds",
        score2.getTotalFirsts() + score2.getTotalSeconds(), is(getNumRounds()));

    // If 1st robot's 1sts = 6, 2nds = 4, then 2nd robot's 1sts = 4, 2nds = 6
    /* Assert.assertThat(
     "1st ranked robot's number of 1st places must be equal to the 2nd ranked robot's number of 2nd places",
     score1.getTotalFirsts(), is(score2.getTotalSeconds()));
View Full Code Here

TOP

Related Classes of robocode.control.snapshot.IScoreSnapshot

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.