private static void turret(RobotController rc) { // do one time things here turtleCorner = turtleCorner == null ? LOCATION_NONE : turtleCorner; try { RobotInfo[] friendlyRobots = rc.senseNearbyRobots(rc.getType().sensorRadiusSquared, rc.getTeam()); if (rc.getHealth() <= 3 && rc.isInfected() && friendlyRobots.length > 0) { rc.disintegrate(); } turretAttack(rc); processFighterSignals(rc); if ((archonIsTooClose(rc) || isAdjacentToWall(rc)) && rc.getType() == RobotType.TURRET && rc.isCoreReady()) { rc.pack(); } if (turtleCorner != LOCATION_NONE && rc.isCoreReady() && rc.getType() == RobotType.TURRET) { int minCornerRadius = (20 + (rc.getRobotCount() / 10)); if (rc.getLocation().distanceSquaredTo(turtleCorner) < minCornerRadius) { rc.pack(); } } rc.setIndicatorString(0, "Turtle x: " + turtleCorner.x + "Turtle y: " + turtleCorner.y); rc.setIndicatorString(1, "I am a turret"); // if (turtleCorner.equals(LOCATION_NONE)) tryToLocateCorner(rc); Clock.yield(); } catch (GameActionException e) { e.printStackTrace(); } }
/** * 1) process signals, try to find turtleCorner 2) if enemies are within sensing radius, unpack 3) * if too close to archons, move away 4) if too close to wall, move away 5) if too close to * corner, move away 6) if it did nothing, unpack * * @param rc */ private static void ttm(RobotController rc) { turtleCorner = turtleCorner.equals(null) ? LOCATION_NONE : turtleCorner; try { RobotInfo[] friendlyRobots = rc.senseNearbyRobots(rc.getType().sensorRadiusSquared, rc.getTeam()); if (rc.getHealth() <= 3 && rc.isInfected() && friendlyRobots.length > 0) { rc.disintegrate(); } // 1) if (isNearbyEnemies(rc) && rc.isCoreReady()) { rc.unpack(); } // 2) processFighterSignals(rc); // 3) moveAwayFromArchons(rc); // 4) moveAwayFromWalls(rc); // 5) if (turtleCorner != LOCATION_NONE) moveFromCorner(rc); // 6) if (rc.isCoreReady() && rc.getType() == RobotType.TTM && rc.getRoundNum() % 25 == 0) rc.unpack(); rc.setIndicatorString(0, "Turtle x: " + turtleCorner.x + "Turtle y: " + turtleCorner.y); rc.setIndicatorString(1, "I am a TTM!"); Clock.yield(); } catch (GameActionException e) { e.printStackTrace(); } }
/** * Working on soldier behavior: 1) If about to die and infected and senses nearby friendly robots, * self destruct 2) Attack if possible 3) Process signals. (If another soldier signals, move * towards that soldier (means there is a zombie den nearby)) 4) Move away from walls / archons 5) * Use position and relative position to turtle corner to move away or toward turtle corner 6) Try * to clear surrounding rubble * * @param rc */ private static void soldier(RobotController rc) { turtleCorner = LOCATION_NONE; while (true) { try { // 1) RobotInfo[] friendlyRobots = rc.senseNearbyRobots(rc.getType().sensorRadiusSquared, rc.getTeam()); if (rc.getHealth() <= 3 && rc.isInfected() && friendlyRobots.length > 0) { rc.disintegrate(); } else { // 2) attackFirst(rc); // 3) processFighterSignals(rc); // 4) moveAwayFromArchons(rc); moveAwayFromWalls(rc); // 5) if (!turtleCorner.equals(LOCATION_NONE)) { moveFromCorner(rc); } else if (currentMode == TRANSITION_MODE) { moveTowardsArchon(rc); } // 6) clearRubble(rc); // if(turtleCorner.equals(LOCATION_NONE)) tryToLocateCorner(rc); } rc.setIndicatorString(0, "Turtle x: " + turtleCorner.x + "Turtle y: " + turtleCorner.y); rc.setIndicatorString(1, "Current Mode" + currentMode); Clock.yield(); } catch (GameActionException e) { e.printStackTrace(); } } }
private static void viper(RobotController rc) { // in case we use vipers later // do one time things here while (true) { rc.disintegrate(); Clock.yield(); } }