public void setup() { //setup defenses redOuterworks[0] = new Defense(); redOuterworks[1] = new Defense(); redOuterworks[2] = new Defense(); redOuterworks[3] = new Defense(); redOuterworks[4] = new Defense(); //setup bots //make some shortcut lables Bot.teleAbility tele1 = Bot.teleAbility.shoot | Bot.teleAbility.climb; Bot.teleAbility tele2 = Bot.teleAbility.breach; Bot.autoAbility auto0 = Bot.autoAbility.none; Bot.autoAbility auto1 = Bot.autoAbility.breach; //build bots redAlliance[0] = new Bot(tele1, auto0,Bot.Alliance.red); redAlliance[1] = new Bot(tele1, auto0, Bot.Alliance.red); redAlliance[2] = new Bot(tele1, auto0, Bot.Alliance.red); blueAlliance[0] = new Bot(tele2,auto1, Bot.Alliance.blue); blueAlliance[1] = new Bot(tele2, auto1, Bot.Alliance.blue); blueAlliance[2] = new Bot(tele2, auto1, Bot.Alliance.blue); for (int i = 0; i < 3; i++) //tell all robots how to find the field { redAlliance[i].field = this; blueAlliance[i].field = this; } }
//bot actions //shooter pattern: // from passage receive ball, // move to neutral, // move to X outerworks, // move to courtyard // high shooter: // move to position // shoot // low shooter: // move to batter // score // move to courtyaard // move to outerworks // move to neutral // move to passage public void runAuto(double timeincr) { mode = botMode.auto; if (canAuto == autoAbility.none) return; //sits in auto if (distancetogo > 0) { distancetogo -= maxSpeed * timeincr; return; //currently driving } if (def != null) { //currently trying to breach a defense //has time elapsed? defenseTimetogo -= timeincr; if (defenseTimetogo < 0) { if (def.attempt()) { //success! field.autoScore += 10; def = null; } else { //fail, try again defenseTimetogo = def.friction; } } } else { destination = strategy.NextLocation(destination); } }
public void run(double timeincr) { //given a time increment do what we can //where do we want to go? mode = botMode.tele; if (distancetogo > 0) { distancetogo -= maxSpeed * timeincr; return; //currently driving } if (def != null) { //currently trying to breach a defense //has time elapsed? defenseTimetogo -= timeincr; if (defenseTimetogo < 0) { if (def.attempt()) { //success! field.teleScore += 5; def = null; } else { //fail, try again defenseTimetogo = def.friction; } } } else { destination = strategy.NextLocation(destination); } }