From 7520de5995e508b93c29043fe73d75af5da523e5 Mon Sep 17 00:00:00 2001 From: Soupdoop Date: Wed, 20 Jan 2016 22:07:32 -0500 Subject: [PATCH 1/4] Did the swarming AI thing Our core archon doesn't move much, but swarm behaves correctly (as outlined in strategy doc) Creates only soldiers --- RobotPlayer.java | 255 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 198 insertions(+), 57 deletions(-) diff --git a/RobotPlayer.java b/RobotPlayer.java index f6f0efd..7c596c6 100644 --- a/RobotPlayer.java +++ b/RobotPlayer.java @@ -51,18 +51,6 @@ public static void run(RobotController r){ Scout s = new RobotPlayer().new Scout(); s.run(); } - else if(selftype == RobotType.GUARD) { - Guard s = new RobotPlayer().new Guard(); - s.run(); - } - else if(selftype == RobotType.SOLDIER) { - Soldier s = new RobotPlayer().new Soldier(); - s.run(); - } - else if(selftype == RobotType.VIPER){ - Viper s = new RobotPlayer().new Viper(); - s.run(); - } else if(selftype == RobotType.TURRET){ Turret s = new RobotPlayer().new Turret(); s.run(); @@ -71,6 +59,10 @@ else if(selftype == RobotType.TTM){ TTM s = new RobotPlayer().new TTM(); s.run(); } + else if(selftype == RobotType.GUARD || selftype == RobotType.SOLDIER || selftype == RobotType.VIPER){ + Swarmer s = new RobotPlayer().new Swarmer(); + s.run(); + } } /** @@ -404,6 +396,152 @@ public void run() { } } + public class Swarmer{ + public static final double SWARM_RATIO = 4.0 / 3; //ratio of all spaces to robots + public MapLocation coreLocation; //location of archon + 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 boolean locked = false; + + public Swarmer(){ + coreLocation = null; + target = null; + moveType = 0; + } + + public void run(){ + while(true) { + try { + Signal[] signals = rc.emptySignalQueue(); + for(int i = 0; i < signals.length; i++){ + if(signals[i].getTeam() == ourTeam){ + FancyMessage s = FancyMessage.getFromRecievedSignal(signals[i]); + if(s.isMessage){ + if(s.type == 0){ //Type 0: give our bots location of archon + coreLocation = s.senderLocation; + }else if(s.type == 1){ //Type 1: give our bots a "stepping stone" location + if(moveType == 0 && !locked){ //ignored if we already have a target, or if in locked mode + moveType = 1; + target = new MapLocation(s.ints.first,s.ints.second); + } + }else if(s.type == 2){ //Type 2: force robots back into regular swarming + locked = true; + moveType = 0; + }else if(s.type == 3){ //Type 3: if in forced swarming, brings back to regular behavior + locked = false; + } + } + } + } + if(moveType != 2 && rc.isWeaponReady()){ + RESOURCE_FUNCTIONS.attackWeakestEnemy(); + } + if(rc.isCoreReady()){ + if(moveType == 0 && coreLocation != null){ + int startDir = randall.nextInt(8); + int[] tryOrder = new int[]{0,1,-1,2,-2,3,-3,4}; + double swarmRadius = RESOURCE_FUNCTIONS.getGoodSwarmRadius(); + MapLocation current = rc.getLocation(); + boolean hasMoved = false; + int minInd = -1; + int minDistance = -1; + for(int i = 0; i < tryOrder.length && !hasMoved; i++){ + MapLocation moveTo = current.add(RESOURCE_FUNCTIONS.intToDir(startDir + tryOrder[i])); + int distance = moveTo.distanceSquaredTo(coreLocation); + if(distance > 2 && distance < (int)(swarmRadius + 1) && rc.canMove(current.directionTo(moveTo))){ + rc.move(current.directionTo(moveTo)); + hasMoved = true; + } + if(rc.canMove(RESOURCE_FUNCTIONS.intToDir(startDir + tryOrder[i]))){ + int newdist = current.add(RESOURCE_FUNCTIONS.intToDir(startDir + tryOrder[i])).distanceSquaredTo(coreLocation); + if(minInd == -1 || newdist < minDistance){ + minInd = i; + minDistance = newdist; + } + } + } + if(!hasMoved && minInd != -1){ + rc.move(RESOURCE_FUNCTIONS.intToDir(startDir + tryOrder[minInd])); + } + if(!locked){ + RobotInfo[] enemiesInSight = rc.senseHostileRobots(rc.getLocation(),rc.getType().sensorRadiusSquared); + for(int i = 0; i < enemiesInSight.length; i++){ + if(enemiesInSight[i].type == RobotType.ARCHON || enemiesInSight[i].type == RobotType.ZOMBIEDEN){ + target = enemiesInSight[i].location; + targetID = enemiesInSight[i].ID; + moveType = 2; + rc.broadcastSignal((int)(rc.getLocation().distanceSquaredTo(coreLocation) * 1.1)); + } + } + } + } + if(moveType == 1){ + int startDir = randall.nextInt(8); + int[] tryOrder = new int[]{0,1,-1,2,-2,3,-3,4}; + int minInd = -1; + int minDistance = -1; + MapLocation current = rc.getLocation(); + for(int i = 0; i < tryOrder.length; 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){ + minInd = i; + minDistance = newdist; + } + } + } + if(minInd != -1){ + rc.move(RESOURCE_FUNCTIONS.intToDir(startDir + tryOrder[minInd])); + } + RobotInfo[] enemiesInSight = rc.senseHostileRobots(rc.getLocation(),rc.getType().sensorRadiusSquared); + for(int i = 0; i < enemiesInSight.length; i++){ + if(enemiesInSight[i].type == RobotType.ARCHON || enemiesInSight[i].type == RobotType.ZOMBIEDEN){ + target = enemiesInSight[i].location; + targetID = enemiesInSight[i].ID; + moveType = 2; + rc.broadcastSignal((int)(rc.getLocation().distanceSquaredTo(coreLocation) * 1.1)); + } + } + } + if(moveType == 2){ + if(rc.canSenseRobot(targetID)){ + RobotInfo rr = rc.senseRobot(targetID); + target = rr.location; + if(rc.isWeaponReady() && rc.canAttackLocation(target)){ + rc.attackLocation(target); + } + }else{ + target = null; + targetID = -1; + moveType = 0; + } + int startDir = randall.nextInt(8); + int[] tryOrder = new int[]{0,1,-1,2,-2,3,-3,4}; + int minInd = -1; + int minDistance = -1; + MapLocation current = rc.getLocation(); + 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){ + minInd = i; + minDistance = newdist; + } + } + } + if(minInd != -1 && rc.isCoreReady()){ + rc.move(RESOURCE_FUNCTIONS.intToDir(startDir + tryOrder[minInd])); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + Clock.yield(); + } + } + } /** * class Archon * @@ -411,18 +549,25 @@ public void run() { * */ private class Archon{ - - public boolean production; - public RobotType decision; + public MapLocation target; + public boolean goToTarget; + public boolean alpha; + /** * Constructor * */ public Archon(){ zombieRounds = rc.getZombieSpawnSchedule().getRounds(); - decision = null; - production = true; + target = null; + goToTarget = false; + if(rc.getLocation().equals(rc.getInitialArchonLocations(ourTeam)[0])){ + alpha = true; + }else{ + target = rc.getInitialArchonLocations(ourTeam)[0]; + goToTarget = true; + } } /** @@ -439,51 +584,42 @@ public void run(){ for(int i = 0; i < signals.length; i++){ if(signals[i].getTeam() == ourTeam){ FancyMessage x = FancyMessage.getFromRecievedSignal(signals[i]); - System.out.println("type is " + x.type); - if(x.isMessage){ - if(x.type == 2){ - mostRecentEnemyArchonLocations.add(new Triple(0,new MapLocation(x.ints.first - 16000,x.ints.second - 16000),rc.getRoundNum())); - } - if(x.type == 3){ - production = false; - } - if(x.type == 4){ - production = true; - } + if(!x.isMessage){ + FancyMessage.sendMessage(1,x.senderLocation.x,x.senderLocation.y,(int)(RESOURCE_FUNCTIONS.getGoodSwarmRadius() * 1.1)); + break; } } } //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(!alpha){ + if(goToTarget && rc.getLocation().distanceSquaredTo(target) > 2){ + RESOURCE_FUNCTIONS.BUG(target); + } + } MapLocation neutral = RESOURCE_FUNCTIONS.findAdjacentNeutralRobot(); if(neutral != null){ rc.activate(neutral); } - if(rc.getRoundNum() % 100 == 0){ - FancyMessage.sendMessage(1, 1, 1, 3); - } - if(decision == null){ - decision = RESOURCE_FUNCTIONS.chooseRobotType(); - } - if(rc.isCoreReady() && production){ - if(RESOURCE_FUNCTIONS.tryBuild(decision)){ //See function in RESOURCE_FUNCTIONS to know what it does + RobotType type = RESOURCE_FUNCTIONS.chooseRobotType(); + if(rc.isCoreReady()){ + if(RESOURCE_FUNCTIONS.tryBuild(type)){ //See function in RESOURCE_FUNCTIONS to know what it does //After building scout, waits a turn, then signals it the location, so it has a good idea of where base is //Also signals the scout which type to become - FancyMessage.sendMessage(4, 0, 0, 6400); - Clock.yield(); - decision = null; - Triple scoutType = getScoutInitType(); + //FancyMessage.sendMessage(4, 0, 0, 6400); + //Clock.yield(); + /*Triple scoutType = getScoutInitType(); //Check if near zombie round if (mostRecentEnemyArchonLocations.size() != 0 && RESOURCE_FUNCTIONS.isCloseToZombieSpawnRound()) { scoutType = getScoutHerdingType(); } - FancyMessage.sendMessage(0,scoutType.first | scoutType.second,scoutType.third,3); - } - else{ - FancyMessage.sendMessage(3, 0, 0, 6400); + FancyMessage.sendMessage(0,scoutType.first | scoutType.second,scoutType.third,3);*/ } + } - movement(); } Clock.yield(); }catch(Exception e){ @@ -723,6 +859,15 @@ public boolean wiggle(MapLocation target) throws GameActionException{ */ public static class RESOURCE_FUNCTIONS{ + public static double getGoodSwarmRadius(){ + int numRobots = rc.getRobotCount(); + double radius = Math.sqrt((Swarmer.SWARM_RATIO * numRobots) / (2 * Math.PI)); + if(radius >= 5){ + return radius; + } + return 5; + } + /** * Direction intToDir * @@ -932,9 +1077,9 @@ public static boolean moveAsFarAwayAsPossibleFrom(MapLocation epicenter) throws * @return RobotType that will be produced */ public static RobotType chooseRobotType() { - for(int i: zombieRounds){ + /*for(int i: zombieRounds){ int currentRound = rc.getRoundNum(); - if(i-currentRound<=40 && i-currentRound>=0){ + if(i-currentRound<=20 && i-currentRound>=0){ return RobotType.SCOUT; } } @@ -945,18 +1090,11 @@ public static RobotType chooseRobotType() { return RobotType.SCOUT; } int fate = randall.nextInt(10); - if(fate < 4){ + if(fate > 1){ return RobotType.SOLDIER; } - if(fate == 9){ - return RobotType.SCOUT; - } - if(fate == 8){ - if(!RESOURCE_FUNCTIONS.zombiesNearby()){ - return RobotType.VIPER; - } - } - return RobotType.GUARD; + return RobotType.GUARD;*/ + return RobotType.SOLDIER; } /** * boolean almostSurrounded @@ -1317,6 +1455,9 @@ public static MapLocation seekNearestPart(){ } return closest; } + public static Direction chooseRandomDirection(){ + return DIRECTIONS[randall.nextInt(DIRECTIONS.length)]; + } } From e0561889dabea2b8307030159e0e47bb87e47ff2 Mon Sep 17 00:00:00 2001 From: Soupdoop Date: Thu, 21 Jan 2016 09:20:05 -0500 Subject: [PATCH 2/4] Small Fix Radius was found to be the square root of what it should be, now fixed. --- RobotPlayer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RobotPlayer.java b/RobotPlayer.java index 7c596c6..e7d22d9 100644 --- a/RobotPlayer.java +++ b/RobotPlayer.java @@ -861,7 +861,7 @@ public static class RESOURCE_FUNCTIONS{ public static double getGoodSwarmRadius(){ int numRobots = rc.getRobotCount(); - double radius = Math.sqrt((Swarmer.SWARM_RATIO * numRobots) / (2 * Math.PI)); + double radius = (Swarmer.SWARM_RATIO * numRobots) / (2 * Math.PI); if(radius >= 5){ return radius; } From a5b5023cf9f07a3c852551ce3697d6fc36665db9 Mon Sep 17 00:00:00 2001 From: Soupdoop Date: Thu, 21 Jan 2016 17:54:10 -0500 Subject: [PATCH 3/4] Tweaks --- RobotPlayer.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/RobotPlayer.java b/RobotPlayer.java index e7d22d9..ec5999a 100644 --- a/RobotPlayer.java +++ b/RobotPlayer.java @@ -401,12 +401,14 @@ public class Swarmer{ public MapLocation coreLocation; //location of archon 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 RobotType targetType; public int targetID; public boolean locked = false; public Swarmer(){ coreLocation = null; target = null; + targetType = null; moveType = 0; } @@ -449,8 +451,12 @@ public void run(){ for(int i = 0; i < tryOrder.length && !hasMoved; i++){ MapLocation moveTo = current.add(RESOURCE_FUNCTIONS.intToDir(startDir + tryOrder[i])); int distance = moveTo.distanceSquaredTo(coreLocation); - if(distance > 2 && distance < (int)(swarmRadius + 1) && rc.canMove(current.directionTo(moveTo))){ - rc.move(current.directionTo(moveTo)); + if(rc.onTheMap(moveTo) && !rc.isLocationOccupied(moveTo) && distance > 2 && distance < (int)(swarmRadius + 1)){ + if(rc.senseRubble(moveTo) > 100){ + rc.clearRubble(current.directionTo(moveTo)); + }else{ + rc.move(current.directionTo(moveTo)); + } hasMoved = true; } if(rc.canMove(RESOURCE_FUNCTIONS.intToDir(startDir + tryOrder[i]))){ @@ -467,7 +473,7 @@ public void run(){ if(!locked){ RobotInfo[] enemiesInSight = rc.senseHostileRobots(rc.getLocation(),rc.getType().sensorRadiusSquared); for(int i = 0; i < enemiesInSight.length; i++){ - if(enemiesInSight[i].type == RobotType.ARCHON || enemiesInSight[i].type == RobotType.ZOMBIEDEN){ + if(enemiesInSight[i].type == RobotType.ARCHON || enemiesInSight[i].type == RobotType.ZOMBIEDEN || enemiesInSight[i].type == RobotType.BIGZOMBIE){ target = enemiesInSight[i].location; targetID = enemiesInSight[i].ID; moveType = 2; @@ -496,9 +502,10 @@ public void run(){ } RobotInfo[] enemiesInSight = rc.senseHostileRobots(rc.getLocation(),rc.getType().sensorRadiusSquared); for(int i = 0; i < enemiesInSight.length; i++){ - if(enemiesInSight[i].type == RobotType.ARCHON || enemiesInSight[i].type == RobotType.ZOMBIEDEN){ + if(enemiesInSight[i].type == RobotType.ARCHON || enemiesInSight[i].type == RobotType.ZOMBIEDEN || enemiesInSight[i].type == RobotType.BIGZOMBIE){ target = enemiesInSight[i].location; targetID = enemiesInSight[i].ID; + targetType = enemiesInSight[i].type; moveType = 2; rc.broadcastSignal((int)(rc.getLocation().distanceSquaredTo(coreLocation) * 1.1)); } @@ -513,6 +520,7 @@ public void run(){ } }else{ target = null; + targetType = null; targetID = -1; moveType = 0; } @@ -524,7 +532,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.ARCHON || newdist > 2)){ minInd = i; minDistance = newdist; } From 0f1e4396e385c044fa7551508a9e8a4571c460ed Mon Sep 17 00:00:00 2001 From: Soupdoop Date: Mon, 25 Jan 2016 17:57:35 -0500 Subject: [PATCH 4/4] Update RobotPlayer.java --- RobotPlayer.java | 108 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 76 insertions(+), 32 deletions(-) diff --git a/RobotPlayer.java b/RobotPlayer.java index ec5999a..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); } @@ -401,14 +401,13 @@ public class Swarmer{ public MapLocation coreLocation; //location of archon 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 RobotType targetType; public int targetID; + public RobotType targetType = null; public boolean locked = false; public Swarmer(){ coreLocation = null; target = null; - targetType = null; moveType = 0; } @@ -432,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); @@ -451,12 +464,8 @@ public void run(){ for(int i = 0; i < tryOrder.length && !hasMoved; i++){ MapLocation moveTo = current.add(RESOURCE_FUNCTIONS.intToDir(startDir + tryOrder[i])); int distance = moveTo.distanceSquaredTo(coreLocation); - if(rc.onTheMap(moveTo) && !rc.isLocationOccupied(moveTo) && distance > 2 && distance < (int)(swarmRadius + 1)){ - if(rc.senseRubble(moveTo) > 100){ - rc.clearRubble(current.directionTo(moveTo)); - }else{ - rc.move(current.directionTo(moveTo)); - } + if(distance > 2 && distance < (int)(swarmRadius + 1) && rc.canMove(current.directionTo(moveTo))){ + rc.move(current.directionTo(moveTo)); hasMoved = true; } if(rc.canMove(RESOURCE_FUNCTIONS.intToDir(startDir + tryOrder[i]))){ @@ -473,7 +482,7 @@ public void run(){ if(!locked){ RobotInfo[] enemiesInSight = rc.senseHostileRobots(rc.getLocation(),rc.getType().sensorRadiusSquared); for(int i = 0; i < enemiesInSight.length; i++){ - if(enemiesInSight[i].type == RobotType.ARCHON || enemiesInSight[i].type == RobotType.ZOMBIEDEN || enemiesInSight[i].type == RobotType.BIGZOMBIE){ + if(enemiesInSight[i].type == RobotType.ARCHON || enemiesInSight[i].type == RobotType.ZOMBIEDEN){ target = enemiesInSight[i].location; targetID = enemiesInSight[i].ID; moveType = 2; @@ -502,10 +511,9 @@ public void run(){ } RobotInfo[] enemiesInSight = rc.senseHostileRobots(rc.getLocation(),rc.getType().sensorRadiusSquared); for(int i = 0; i < enemiesInSight.length; i++){ - if(enemiesInSight[i].type == RobotType.ARCHON || enemiesInSight[i].type == RobotType.ZOMBIEDEN || enemiesInSight[i].type == RobotType.BIGZOMBIE){ + if(enemiesInSight[i].type == RobotType.ARCHON || enemiesInSight[i].type == RobotType.ZOMBIEDEN){ target = enemiesInSight[i].location; targetID = enemiesInSight[i].ID; - targetType = enemiesInSight[i].type; moveType = 2; rc.broadcastSignal((int)(rc.getLocation().distanceSquaredTo(coreLocation) * 1.1)); } @@ -515,12 +523,12 @@ 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); } }else{ target = null; - targetType = null; targetID = -1; moveType = 0; } @@ -532,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) && (targetType == RobotType.ARCHON || newdist > 2)){ + if((minInd == -1 || newdist < minDistance) && (targetType != RobotType.ZOMBIEDEN || newdist > 2)){ minInd = i; minDistance = newdist; } @@ -596,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); @@ -696,6 +722,7 @@ private class Scout{ */ public Scout(){ disciples = 0; + base = rc.getLocation(); } /** @@ -708,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++){ @@ -731,7 +758,8 @@ public void run(){ } } } - } + }*/ + runAsArchonSearcher(); } } @@ -740,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); @@ -869,7 +900,7 @@ public static class RESOURCE_FUNCTIONS{ public static double getGoodSwarmRadius(){ int numRobots = rc.getRobotCount(); - double radius = (Swarmer.SWARM_RATIO * numRobots) / (2 * Math.PI); + double radius = Math.sqrt((Swarmer.SWARM_RATIO * numRobots) / (2 * Math.PI)); if(radius >= 5){ return radius; } @@ -924,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 @@ -1090,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; } /** @@ -1412,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){