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); } }
//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 Bot(teleAbility kind, autoAbility autoKind, Alliance side) { canShoot = kind.HasFlag(teleAbility.shoot); canClimb = kind.HasFlag(teleAbility.climb); canBreach = kind.HasFlag(teleAbility.breach); canAuto = autoKind; hasBall = true; //let each robot start with a ball mode = botMode.none; strategy = new BotStrategy(this); location.current = fieldLocation.places.neutral; destination = fieldLocation.places.not_set; distancetogo = 0; team = side; maxSpeed = 5.0; //default to 5 fps }
//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); } }