Package net.sf.robocode.battle.peer

Examples of net.sf.robocode.battle.peer.TeamPeer


    Map<String, TeamPeer> namedTeams = new HashMap<String, TeamPeer>();

    // create robots
    for (int i = 0; i < battlingRobotsList.length; i++) {
      RobotSpecification specification = battlingRobotsList[i];
      TeamPeer team = null;

      String teamFullName = HiddenAccess.getRobotTeamName(specification);

      // The team index and robot index depends on current sizes of the contestant list and robot list
      int teamIndex = contestants.size();
      int robotIndex = robots.size();

      if (teamFullName != null) {
        if (!namedTeams.containsKey(teamFullName)) {
          String newTeamName = teamDuplicates.get(teams.indexOf(teamFullName));

          team = new TeamPeer(newTeamName, teamMembers.get(teamFullName), teamIndex);

          namedTeams.put(teamFullName, team);
          contestants.add(team);

        } else {
          team = namedTeams.get(teamFullName);
          if (team != null) {
            teamIndex = team.getTeamIndex();
          }
        }
      }
      Integer duplicate = robotDuplicates.get(i);
      RobotPeer robotPeer = new RobotPeer(this, hostManager, specification, duplicate, team, robotIndex);
View Full Code Here


            robotPeer.println("SYSTEM: game aborted.");
          }
        }
      } else if (oneTeamRemaining()) {
        boolean leaderFirsts = false;
        TeamPeer winningTeam = null;

        robocode.RoundEndedEvent roundEndedEvent = new robocode.RoundEndedEvent(getRoundNum(), currentTime,
            totalTurns);

        for (RobotPeer robotPeer : getRobotsAtRandom()) {
          robotPeer.addEvent(roundEndedEvent);
          if (robotPeer.isAlive() && !robotPeer.isWinner() && !robotPeer.isSentryRobot()) {
            robotPeer.getRobotStatistics().scoreLastSurvivor();
            robotPeer.setWinner(true);
            robotPeer.println("SYSTEM: " + robotPeer.getNameForEvent(robotPeer) + " wins the round.");
            robotPeer.addEvent(new WinEvent());
            if (robotPeer.getTeamPeer() != null) {
              if (robotPeer.isTeamLeader()) {
                leaderFirsts = true;
              } else {
                winningTeam = robotPeer.getTeamPeer();
              }
            }
          }
          // Generate totals as round has ended, but first when the last scores has been calculated
          robotPeer.getRobotStatistics().generateTotals();
        }
        if (!leaderFirsts && winningTeam != null) {
          winningTeam.getTeamLeader().getRobotStatistics().scoreFirsts();
        }
      }
      if (isAborted() || isLastRound()) {
        List<RobotPeer> orderedRobots = new ArrayList<RobotPeer>(robots);
        Collections.sort(orderedRobots);
View Full Code Here

    if (countActiveParticipants() <= 1) {
      return true;
    }

    boolean found = false;
    TeamPeer currentTeam = null;

    for (RobotPeer currentRobot : robots) {
      if (currentRobot.isAlive()) {
        if (!found) {
          found = true;
View Full Code Here

TOP

Related Classes of net.sf.robocode.battle.peer.TeamPeer

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.