From 2c5b21f57e9c911eb818396043bec33e3e23691b Mon Sep 17 00:00:00 2001 From: androidmage Date: Fri, 8 Jan 2016 00:08:58 -0500 Subject: [PATCH] Guards now move out but not completely controlled --- RobotPlayer.java | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/RobotPlayer.java b/RobotPlayer.java index 638b73d..e39847a 100644 --- a/RobotPlayer.java +++ b/RobotPlayer.java @@ -67,6 +67,22 @@ public Guard() { public void run() { while(true){ try{ + Signal[] signals = rc.emptySignalQueue(); + if(signals.length > 0){ //if == 0, no signals, so not ready + for(Signal s: signals){ + if(s.getTeam() == rc.getTeam() && rc.senseRobot(s.getID()).type == RobotType.ARCHON){ + FancyMessage f = FancyMessage.getFromRecievedSignal(s); + MapLocation archonLocation = f.senderLocation; + Direction archonDirection = rc.getLocation().directionTo(archonLocation); + Direction oppositeDirection = RESOURCE_FUNCTIONS.getOpposite(archonDirection); + if(rc.isCoreReady()){ + if(rc.canMove(oppositeDirection)){ + rc.move(oppositeDirection); + } + } + } + } + } if(rc.isWeaponReady()){ RobotInfo[] robots = rc.senseNearbyRobots(3, Team.ZOMBIE); for(RobotInfo robot: robots) { @@ -112,6 +128,9 @@ public void run(){ try{ //If it can, always tries to build Scouts. if(rc.isCoreReady()){ + if(rc.getRoundNum() % 100 == 0){ + FancyMessage.sendMessage(1, 1, 1, 3); + } RobotType type = RESOURCE_FUNCTIONS.chooseRobotType(); 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 @@ -589,6 +608,38 @@ public static boolean BUG(MapLocation target) throws GameActionException{ rc.setIndicatorString(0,"Failed outside of branch"); return false; } + + /** + * + * MapLocation getOpposite + * @param A direction + * @return Returns the opposite direction of the given direction + * + */ + public static Direction getOpposite(Direction archonDirection){ + if(archonDirection.equals(Direction.NORTH)){ + return Direction.SOUTH; + } + if(archonDirection.equals(Direction.SOUTH)){ + return Direction.NORTH; + } + if(archonDirection.equals(Direction.EAST)){ + return Direction.WEST; + } + if(archonDirection.equals(Direction.WEST)){ + return Direction.EAST; + } + if(archonDirection.equals(Direction.NORTH_EAST)){ + return Direction.SOUTH_WEST; + } + if(archonDirection.equals(Direction.NORTH_WEST)){ + return Direction.SOUTH_EAST; + } + if(archonDirection.equals(Direction.SOUTH_EAST)){ + return Direction.NORTH_WEST; + } + return Direction.NORTH_EAST; + } } /**