I've been working on a team myself, and the radar strategy I use seems to be working well enough... It looks something like this: public void run() { // each turn, find the most outdated scan if(target == null) { Lib.Other oldest = data.getOldest(); if(lastTarget == null || oldest.getSource() == Lib.Other.Source.SCAN || oldest.getAge(robot) - lastTarget.getAge(robot) > 3) { target = oldest; } else { target = lastTarget; } } // default radar turn is spin in circles forever double radarTurn = Double.POSITIVE_INFINITY; // if (a) we have an oldest enemy // (b) the scan of them is vaguely recent // (c) we have at least a little bit of // data on ALL the robots on the field if(target != null && target.getAge(robot) <= 9 && data.allKnown()) { // turn the radar to the most outdated enemy // to refresh our data on them radarTurn = Utils.normalRelativeAngle(robot.getRadarHeadingRadians() - GeoUtils.getAbsoluteBearing(robot.getLocation(), target.guess(robot))); // multiply the radar turn by the turn factor // of 2.2 to create a larger arc radarTurn *= 2.2; } // make the turn robot.setTurnRadarLeftRadians(radarTurn); // reset the target lastTarget = target; target = null; } The data is handled in another class (clearly), and so is the communication (the data has all the latest scans of all enemy robots as compiled by all teammates). The idea is to turn to the enemy who you have the oldest data on, but with a slight bias towards the enemy you're already scanning (so if all the scans are relatively new, the teammates will continue to scan the enemy they're scanning, for more perfect data). I've wrote a short method to have the robot paint red dots where it thinks the enemies are, and they're almost always right... What do you think? --Bayen * Just changed your code tags to pre tags to fix the formatting -- CharlieN
|