@Override public void initialize() throws GameActionException { if (rc.getRoundNum() != 0) { return; } Signal[] signals = rc.emptySignalQueue(); rc.broadcastSignal(GameConstants.MAP_MAX_HEIGHT * GameConstants.MAP_MAX_HEIGHT); for (Signal s : signals) { if (s.getTeam() == myTeam) { heiarchy++; } } rc.setIndicatorString(1, "I am the " + heiarchy + ": " + rc.getRoundNum()); if (heiarchy == -1) { goalLocation = rc.getLocation(); rc.broadcastMessageSignal(1337, 0, 100 * 100); leaderId = rc.getID(); leaderLocation = rc.getLocation(); } else { heiarchy -= 1; for (Signal s : signals) { if (s.getMessage() != null) { if (s.getMessage()[0] == 1337) { leaderId = s.getID(); leaderLocation = s.getLocation(); goalLocation = leaderLocation; break; } } } } }
private static Direction getScoutTargetDirection(RobotController rc) { Signal[] signals = rc.emptySignalQueue(); for (Signal signal : signals) { if (signal.getMessage() != null && signal.getTeam().equals(myTeam)) { if (signal.getMessage()[0] == SENDING_TARGET_DIRECTION) { return SIGNAL_TO_DIRECTION.get(signal.getMessage()[1]); } } } return Direction.NONE; }
/** * Message-processing for non-archons Currently handles messages: Change of mode Setting * turtle-corner location * * @param rc * @throws GameActionException */ private static void processFighterSignals(RobotController rc) throws GameActionException { int cornerX = Integer.MIN_VALUE; int cornerY = Integer.MIN_VALUE; RobotType type = rc.getType(); Signal[] signals = rc.emptySignalQueue(); for (Signal s : signals) { if (s.getTeam().equals(myTeam) && s.getMessage() != null) { final int[] message = s.getMessage(); if (message[0] == SENDING_MODE) { currentMode = message[1]; } else if (message[0] == SENDING_TURTLE_X) { cornerX = message[1]; } else if (message[0] == SENDING_TURTLE_Y) { cornerY = message[1]; } } // when a soldier finds a zombie den, it signals. Other soldiers that receive // the message then should move toward the den to help kill it. Ideally, // this should make it easier to remove zombie dens near the turtle corner if (type == RobotType.SOLDIER && s.getTeam().equals(myTeam) && s.getMessage() == null) { if (rc.getLocation().distanceSquaredTo(s.getLocation()) < rc.getType().sensorRadiusSquared * 2.5 && rc.isCoreReady()) { moveTowards(rc, rc.getLocation().directionTo(s.getLocation())); } } // for turrets to attack broadcasting enemies outside of sight range if (type == RobotType.TURRET && !s.getTeam().equals(myTeam) && rc.isWeaponReady() && rc.canAttackLocation(s.getLocation())) { rc.attackLocation(s.getLocation()); } } if (cornerX > Integer.MIN_VALUE && cornerY > Integer.MIN_VALUE) { turtleCorner = new MapLocation(cornerX, cornerY); } }
private RobotData getZombieDen() { for (Signal s : roundSignals) { if (s.getTeam() != team) continue; int[] message = s.getMessage(); if (message == null) continue; MessageParser parser = new MessageParser(message[0], message[1], currentLocation); if (parser.getMessageType() == MessageType.ZOMBIE) { RobotData robotData = parser.getRobotData(); if (robotData.type == RobotType.ZOMBIEDEN) { return robotData; } } } return null; }
public void getSignals() { Signal[] queue = rc.emptySignalQueue(); for (Signal signal : queue) { if (signal.getTeam() == myTeam) { if (signal.getMessage() != null) { if (signal.getMessage()[0] == 0xdead && signal.getMessage()[1] == 0xbeef) { heiarchy--; continue; } MessageSignal msgSig = new MessageSignal(signal); switch (msgSig.getMessageType()) { case ROBOT: if (msgSig.getPingedTeam() == Team.NEUTRAL) { rc.setIndicatorString(0, "Found neutral"); if (msgSig.getPingedLocation().distanceSquaredTo(rc.getLocation()) < 40) { goalLocation = msgSig.getPingedLocation(); } } if (msgSig.getPingedType() == RobotType.ARCHON && msgSig.getPingedTeam() == myTeam.opponent()) { rc.setIndicatorString(0, "Found enemy Archon"); foundEnemyArchon = true; sentGoal = false; enemyArchon = msgSig.getPingedLocation(); } if (msgSig.getPingedType() == RobotType.ZOMBIEDEN) { rc.setIndicatorString(2, "Found Zombie Den"); knownZombieDenLocations.add(msgSig.getPingedLocation()); foundZombieDen = true; } break; case PARTS: break; default: break; } } } } }
/** * To be run by archons during the intro phase (and others? change it a bit?) to handle and gather * information from incoming message signals * * @param rc */ private static void processIntroMessageSignals(RobotController rc) { int cornerX = Integer.MIN_VALUE; int cornerY = Integer.MIN_VALUE; int denX = Integer.MIN_VALUE; int denY = Integer.MIN_VALUE; Signal[] signals = rc.emptySignalQueue(); for (Signal s : signals) { if (s.getTeam().equals(myTeam) && s.getMessage() != null) { final int[] message = s.getMessage(); if (message[0] == SENDING_CORNER_X) { cornerX = message[1]; } else if (message[0] == SENDING_CORNER_Y) { cornerY = message[1]; } else if (message[0] == SENDING_DEN_X) { denX = message[1]; } else if (message[0] == SENDING_DEN_Y) { denY = message[1]; } } } if (cornerX > Integer.MIN_VALUE && cornerY > Integer.MIN_VALUE) { MapLocation newCorner = new MapLocation(cornerX, cornerY); if (!SCOUTED_CORNERS.contains(newCorner)) { SCOUTED_CORNERS.add(newCorner); rc.setIndicatorString(0, "Added new corner: " + newCorner); rc.setIndicatorString(2, "Current Mode" + currentMode); } rc.setIndicatorString(1, SCOUTED_CORNERS + ""); } if (denX > Integer.MIN_VALUE && denY > Integer.MIN_VALUE) { MapLocation newDen = new MapLocation(denX, denY); if (!ZOMBIE_DEN_LOCATIONS.contains(newDen)) { ZOMBIE_DEN_LOCATIONS.add(newDen); } } }