Exemplo n.º 1
0
  public LXXPoint getDestination(boolean newSession) {
    double angle = robot.getHeadingRadians() + Math.PI / 2;
    LXXPoint res1 = new LXXPoint(robot.getX(), robot.getY());
    res1.x += sin(angle) * 85;
    res1.y += cos(angle) * 85;
    double d1 = res1.distance(robot.getBattleFieldWidth() / 2, robot.getBattleFieldHeight() / 2);

    angle = robot.getHeadingRadians() - Math.PI / 2;
    LXXPoint res2 = new LXXPoint(robot.getX(), robot.getY());
    res2.x += sin(angle) * 85;
    res2.y += cos(angle) * 85;
    double d2 = res2.distance(robot.getBattleFieldWidth() / 2, robot.getBattleFieldHeight() / 2);

    return d1 < d2 ? res1 : res2;
  }
Exemplo n.º 2
0
  public boolean match() {
    for (Iterator<Hit> iter = hits.iterator(); iter.hasNext(); ) {
      Hit h = iter.next();
      if (robot.getTime() - h.time > 20) {
        iter.remove();
      }
    }
    double avgBearing = 0;
    for (Hit h : hits) {
      avgBearing += h.heading;
    }
    avgBearing /= hits.size();

    // todo (zhidkov): fix name
    double maxHz = 0;
    for (Hit h : hits) {
      if (abs(h.heading - avgBearing) > maxHz) {
        maxHz = abs(h.heading - avgBearing);
      }
    }
    return abs(avgBearing - maxHz) < LXXConstants.RADIANS_45 && hits.size() > 1;
  }
Exemplo n.º 3
0
 public HitReactStrategy(BasicRobot robot) {
   this.robot = robot;
   robot.addListener(this);
 }