public static void run(RobotController theRC) { rc = theRC; // These don't change so get them once and use the local variable (performance) myType = rc.getType(); myTeam = rc.getTeam(); enemyTeam = myTeam.opponent(); myHQ = rc.senseHQLocation(); myLoc = rc.getLocation(); senseRange = myType.sensorRadiusSquared; attackRange = myType.attackRadiusSquared; maxRounds = rc.getRoundLimit(); if (myType == RobotType.MISSILE) runMissile(); if (myType.canMove()) { bfs = new Bfs(rc); // We need to check the breadth first search results to move optimally } threats = new Threats(rc); if (myType == RobotType.HQ) runHQ(); else if (myType == RobotType.TOWER) runTower(); else if (myType.isBuilding) runBuilding(); else if (myType.canBuild()) runBeaver(); else if (myType.canMine()) runMiner(); // Includes Beavers else if (myType == RobotType.DRONE) runDrone(); else if (myType.canAttack() || myType == RobotType.LAUNCHER) runCombat(); else runOther(); }
// Computers private static void runOther() { int numTowers = -1; while (true) { threats.update(); myLoc = rc.getLocation(); // Move if we can and want to if (rc.isCoreReady() && myType.canMove()) { if (shouldRetreat()) doRetreatMove(); // Pull back if in range of the enemy guns else doAdvanceMove(); // Move towards our HQ } doTransfer(); // Perform a background breadth first search to the enemy HQ if (myType == RobotType.COMPUTER && Clock.getBytecodesLeft() > 1000) { bfs.work(threats.enemyHQ, Bfs.PRIORITY_HIGH, 1000, numTowers != threats.enemyTowers.length); } numTowers = threats.enemyTowers.length; rc.yield(); } }