diff --git a/RobotPlayer.java b/RobotPlayer.java index 7c596c6..9888b98 100644 --- a/RobotPlayer.java +++ b/RobotPlayer.java @@ -109,7 +109,7 @@ public void run() { rc.attackLocation(target); } else{ - Direction rubbleDirection = RESOURCE_FUNCTIONS.clearRubbleForPath(enemyArchonLocation); + Direction rubbleDirection = RESOURCE_FUNCTIONS.findRubbleDirection(); if(rubbleDirection != null){ rc.clearRubble(rubbleDirection); } @@ -274,7 +274,7 @@ public void run() { }*/ RESOURCE_FUNCTIONS.attackWeakestEnemy(); if(rc.isWeaponReady()){ - Direction rubbleDirection = RESOURCE_FUNCTIONS.clearRubbleForPath(enemyArchonLocation); + Direction rubbleDirection = RESOURCE_FUNCTIONS.findRubbleDirection(); if(rubbleDirection != null){ rc.clearRubble(rubbleDirection); } @@ -402,6 +402,7 @@ public class Swarmer{ public MapLocation target; //location of hostile target [zombiedens, enemyarchons] public int moveType; //type of movement: 0==movement around friendly archon, 1==movement towards "stepping stone target", 2==movement towards hostile target public int targetID; + public RobotType targetType = null; public boolean locked = false; public Swarmer(){ @@ -430,13 +431,27 @@ public void run(){ moveType = 0; }else if(s.type == 3){ //Type 3: if in forced swarming, brings back to regular behavior locked = false; + }else if(s.type == 5){ + target = new MapLocation(s.ints.first, s.ints.second); + moveType = 1; } } } } if(moveType != 2 && rc.isWeaponReady()){ RESOURCE_FUNCTIONS.attackWeakestEnemy(); + //if has not attacked yet + if(rc.isWeaponReady()) { + Direction rubbleDirection = RESOURCE_FUNCTIONS.clearRubbleForPath(target); + if(rubbleDirection == null) { + rubbleDirection = RESOURCE_FUNCTIONS.findRubbleDirection(); + } + if(rubbleDirection != null && rc.isCoreReady()){ + rc.clearRubble(rubbleDirection); + } + } } + if(rc.isCoreReady()){ if(moveType == 0 && coreLocation != null){ int startDir = randall.nextInt(8); @@ -508,6 +523,7 @@ public void run(){ if(rc.canSenseRobot(targetID)){ RobotInfo rr = rc.senseRobot(targetID); target = rr.location; + targetType = rr.type; if(rc.isWeaponReady() && rc.canAttackLocation(target)){ rc.attackLocation(target); } @@ -524,7 +540,7 @@ public void run(){ for(int i = 0; i < tryOrder.length && target != null; i++){ if(rc.canMove(RESOURCE_FUNCTIONS.intToDir(startDir + tryOrder[i]))){ int newdist = current.add(RESOURCE_FUNCTIONS.intToDir(startDir + tryOrder[i])).distanceSquaredTo(target); - if(minInd == -1 || newdist < minDistance){ + if((minInd == -1 || newdist < minDistance) && (targetType != RobotType.ZOMBIEDEN || newdist > 2)){ minInd = i; minDistance = newdist; } @@ -588,18 +604,36 @@ public void run(){ FancyMessage.sendMessage(1,x.senderLocation.x,x.senderLocation.y,(int)(RESOURCE_FUNCTIONS.getGoodSwarmRadius() * 1.1)); break; } + else if(alpha && x.type == 4 && !goToTarget && rc.getRobotCount() > 30){ + int xPos = x.ints.first; + int yPos = x.ints.second; + target = new MapLocation(xPos, yPos); + goToTarget = true; + } + else if(!alpha && x.type == 5) { + target = new MapLocation(x.ints.first, x.ints.second); + goToTarget = true; + } } } //If it can, always tries to build Scouts. if(rc.isCoreReady()){ if(alpha && rc.getRoundNum() % 10 == 0){ - FancyMessage.sendMessage(0,0,0,(int)(RESOURCE_FUNCTIONS.getGoodSwarmRadius() * 1.1)); + if(goToTarget) { + FancyMessage.sendMessage(5, target.x, target.y, 1000); + } + else { + FancyMessage.sendMessage(0,0,0,(int)(1000)); + } } if(!alpha){ - if(goToTarget && rc.getLocation().distanceSquaredTo(target) > 2){ + if(goToTarget && rc.getRoundNum() % 2 == 0 && rc.getLocation().distanceSquaredTo(target) > 2){ RESOURCE_FUNCTIONS.BUG(target); } } + if(goToTarget && alpha) { + RESOURCE_FUNCTIONS.BUG(target); + } MapLocation neutral = RESOURCE_FUNCTIONS.findAdjacentNeutralRobot(); if(neutral != null){ rc.activate(neutral); @@ -688,6 +722,7 @@ private class Scout{ */ public Scout(){ disciples = 0; + base = rc.getLocation(); } /** @@ -700,7 +735,7 @@ public Scout(){ */ public void run(){ while(true){ - if(base == null){ + /*if(base == null){ Signal[] signals = rc.emptySignalQueue(); if(signals.length > 0){ for(int i = 0; i < signals.length; i++){ @@ -723,7 +758,8 @@ public void run(){ } } } - } + }*/ + runAsArchonSearcher(); } } @@ -732,10 +768,13 @@ public void runAsArchonSearcher(){ while(!foundArchon){ try{ MapLocation enemyArchonLocation = RESOURCE_FUNCTIONS.scanArchonLocation(); + if(enemyArchonLocation == null) { + enemyArchonLocation = RESOURCE_FUNCTIONS.scanZombieDen(); + } if(enemyArchonLocation != null){ int xPos = enemyArchonLocation.x; int yPos = enemyArchonLocation.y; - FancyMessage.sendMessage(2, xPos + 16000, yPos + 16000, 1000); + FancyMessage.sendMessage(4, xPos, yPos, 6400); foundArchon = true; }else if(rc.isCoreReady()){ RESOURCE_FUNCTIONS.moveAsFarAwayAsPossibleFrom(base); @@ -916,6 +955,17 @@ public static MapLocation scanFriendlyArchonLocation() { } return null; } + public static MapLocation scanZombieDen() { + RobotInfo[] zombies = rc.senseNearbyRobots(rc.getType().sensorRadiusSquared, Team.ZOMBIE); + if(zombies != null) { + for(RobotInfo zombie: zombies) { + if(zombie.type.equals(RobotType.ZOMBIEDEN)) { + return zombie.location; + } + } + } + return null; + } /** * int dirToInt @@ -1082,18 +1132,11 @@ public static RobotType chooseRobotType() { if(i-currentRound<=20 && i-currentRound>=0){ return RobotType.SCOUT; } - } - if(almostSurrounded()){ - return RobotType.SCOUT; - } - if(numberOfRobotsInRadiusAndThoseRobots(RobotType.GUARD,3,ourTeam).first == 7){ + }*/ + int fate = randall.nextInt(20); + if(fate == 0){ return RobotType.SCOUT; } - int fate = randall.nextInt(10); - if(fate > 1){ - return RobotType.SOLDIER; - } - return RobotType.GUARD;*/ return RobotType.SOLDIER; } /** @@ -1404,11 +1447,20 @@ public static MapLocation viperAttackTarget(){ } public static Direction clearRubbleForPath(MapLocation enemyArchonLocation){ Direction enemyArchonDirection = rc.getLocation().directionTo(enemyArchonLocation); - if(enemyArchonDirection != null && rc.senseRubble(rc.getLocation().add(enemyArchonDirection)) > 0){ + if(enemyArchonDirection != null && rc.senseRubble(rc.getLocation().add(enemyArchonDirection)) > 50){ return enemyArchonDirection; } return null; } + public static Direction findRubbleDirection(){ + for(Direction direction: DIRECTIONS) { + MapLocation rubbleLocation = rc.getLocation().add(direction); + if(rc.senseRubble(rubbleLocation) > 50) { + return direction; + } + } + return null; + } public static Direction nearestRubble(){ for(Direction direction: DIRECTIONS){ if(rc.senseRubble(rc.getLocation().add(direction)) > 100){