diff --git a/RobotPlayer.java b/RobotPlayer.java index d0e229d..986efc6 100644 --- a/RobotPlayer.java +++ b/RobotPlayer.java @@ -66,14 +66,15 @@ public Guard() { public void run() { while(true){ try{ - if(rc.isCoreReady()){ - RobotInfo[] robots = rc.senseNearbyRobots(1, Team.ZOMBIE); + if(rc.isWeaponReady()){ + RobotInfo[] robots = rc.senseNearbyRobots(3, Team.ZOMBIE); for(RobotInfo robot: robots) { if(rc.canAttackLocation(robot.location)) { rc.attackLocation(robot.location); + break; } } - rc.move(Direction.EAST); + //rc.move(Direction.EAST); } Clock.yield(); }catch(Exception e){ @@ -459,11 +460,28 @@ public static RobotType chooseRobotType() { return RobotType.SCOUT; } } - if(Math.random()*10>1) { + if(Math.random()*3>1) { + return RobotType.SCOUT; + } + if(numberOfRobotsInRadius(RobotType.GUARD,3,ourTeam) == 7){ return RobotType.SCOUT; } return RobotType.GUARD; } + + public static int numberOfRobotsInRadius(RobotType type,int radiusSqr,Team team){ + int count = 0; + RobotInfo[] robats = rc.senseNearbyRobots(radiusSqr,team); + if(type == null){ + return robats.length; + } + for(int i = 0; i < robats.length; i++){ + if(robats[i].type.equals(type)){ + count++; + } + } + return count; + } } /**