コード例 #1
0
  @Override
  public void onStep(Controller controller, Snapshot snapshot) throws ConfusedException {

    // get our robot and the ball
    Robot ourRobot = snapshot.getBalle();
    Ball ball = snapshot.getBall();

    // if neither the ball nor the robot can be found then return
    if ((ourRobot.getPosition() == null) || (ball.getPosition() == null)) {
      return;
    }

    Strategy strategy = getStrategy(snapshot);
    LOG.debug("Selected strategy: " + strategy.getClass().getName());

    // use strategy that was chosen
    setCurrentStrategy(strategy.getClass().getName());

    try {

      strategy.step(controller, snapshot);

    } catch (ConfusedException e) {

      // If a strategy does not know what to do
      LOG.error("Wut Wut?", e);
      // Default to goToBallPFN
      Intercept.step(controller, snapshot);
    }
  }