From 6824fe6d20f3a12fd05a97bae08769f21ebc92b2 Mon Sep 17 00:00:00 2001 From: androidmage Date: Thu, 14 Jan 2016 13:59:34 -0500 Subject: [PATCH] Implemented vipers but doesn't work very well --- RobotPlayer.java | 77 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 8 deletions(-) diff --git a/RobotPlayer.java b/RobotPlayer.java index c50c736..6db2994 100644 --- a/RobotPlayer.java +++ b/RobotPlayer.java @@ -111,7 +111,10 @@ public void run() { RESOURCE_FUNCTIONS.BUG(enemyArchonLocation); } if(rc.isWeaponReady()){ - RESOURCE_FUNCTIONS.attackWeakestEnemy(); + MapLocation target = RESOURCE_FUNCTIONS.viperAttackTarget(); + if(rc.canAttackLocation(target)){ + rc.attackLocation(target); + } } Clock.yield(); } catch (Exception e) { @@ -387,6 +390,9 @@ public void run() { * */ private class Archon{ + + public boolean ViperProduction; + public boolean production; /** * Constructor @@ -394,6 +400,8 @@ private class Archon{ */ public Archon(){ zombieRounds = rc.getZombieSpawnSchedule().getRounds(); + ViperProduction = false; + production = true; } /** @@ -410,10 +418,19 @@ 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; + ViperProduction = false; + } + if(x.type == 4){ + production = true; + ViperProduction = false; + } } } } @@ -424,7 +441,19 @@ public void run(){ FancyMessage.sendMessage(1, 1, 1, 3); } RobotType type = RESOURCE_FUNCTIONS.chooseRobotType(); - if(rc.isCoreReady() && RESOURCE_FUNCTIONS.tryBuild(type)){ //See function in RESOURCE_FUNCTIONS to know what it does + if(!ViperProduction && production && type == RobotType.VIPER){ + production = false; + ViperProduction = true; + FancyMessage.sendMessage(3, 0, 0, 1000); + } + if(!production && ViperProduction && RESOURCE_FUNCTIONS.tryBuild(RobotType.VIPER)){ + ViperProduction = false; + System.out.println("success"); + production = true; + FancyMessage.sendMessage(4, 0, 0, 1000); + type = RESOURCE_FUNCTIONS.chooseRobotType(); + } + if(rc.isCoreReady() && production && 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 Clock.yield(); @@ -866,22 +895,25 @@ public static RobotType chooseRobotType() { return RobotType.SCOUT; } } - if(Math.random()*3>1) { - return RobotType.SCOUT; - } if(almostSurrounded()){ return RobotType.SCOUT; } if(numberOfRobotsInRadiusAndThoseRobots(RobotType.GUARD,3,ourTeam).first == 7){ return RobotType.SCOUT; } - int fate = randall.nextInt(3); - if(fate == 0){ + int fate = randall.nextInt(10); + if(fate < 3){ return RobotType.SOLDIER; } - if(fate == 1){ + if(fate > 6){ return RobotType.SCOUT; } + if(fate == 4){ + int more_fate = randall.nextInt(2); + if(!RESOURCE_FUNCTIONS.zombiesNearby() && more_fate == 0){ + return RobotType.VIPER; + } + } return RobotType.GUARD; } /** @@ -1157,6 +1189,35 @@ public static MapLocation locateStrongestEnemy(){ } return null; } + public static boolean zombiesNearby(){ + RobotInfo[] enemies = rc.senseNearbyRobots(rc.getType().sensorRadiusSquared, Team.ZOMBIE); + if(enemies != null && enemies.length > 1){ + return true; + } + return false; + } + public static MapLocation viperAttackTarget(){ + RobotInfo[] sensedRobots = rc.senseNearbyRobots(RobotType.VIPER.attackRadiusSquared, opponentTeam); + RobotInfo target = null; + if(sensedRobots != null){ + for(RobotInfo robot: sensedRobots){ + if(target == null || robot.health