Ejemplo n.º 1
0
 public static void run(RobotController _rc) throws Exception {
   switch (_rc.getType()) {
     case ARCHON:
       Archon.run(_rc);
       break;
     case GUARD:
       Guard.run(_rc);
       break;
     case SCOUT:
       Scout.run(_rc);
       break;
     case SOLDIER:
       Soldier.run(_rc);
       break;
     case TTM:
     case TURRET:
       Turret.run(_rc);
       break;
     case VIPER:
       Viper.run(_rc);
       break;
     default:
       // this shouldn't happen
       throw new Exception("I am a bad robot.");
   }
 }
Ejemplo n.º 2
0
 public int compareTo(Scout s) {
   if (marks == s.getMarks()) {
     return dateOfBirth.compareTo(s.getDateOfBirth());
   }
   return marks - s.getMarks();
 }
Ejemplo n.º 3
0
  /**
   * Implements Scout moving model.
   *
   * @param board
   * @param sct
   * @return
   */
  public List<Vector2D> movementSystemScout(Board board, Scout sct) {
    List<Vector2D> sctMovements = new ArrayList<Vector2D>();
    // move in each direction until hitting something:
    int x = sct.getCol();
    int y = sct.getRow();
    // Blocked by:
    // 1.rock (non-inclusive)
    // 2.same player token (non-inclusive)
    // 3.other player token (inclusive)
    // 4.Board boundaries (non-inclusive)
    boolean blocked = false;
    // Negative Y:
    int ny = y;
    while (!blocked) {
      ny--;
      if (isInsideBoard(new Vector2D(ny, x))) {
        Token bt = board.getToken(ny, x);
        if (hitsRock(new Vector2D(ny, x))) {
          blocked = true;
        } else if (bt.getOwn() == this.getTurn().side()) {
          blocked = true;
        } else if (bt.getOwn() == this.getTurn().otherSide()) {
          sctMovements.add(new Vector2D(ny, x));
          blocked = true;
        } else {
          sctMovements.add(new Vector2D(ny, x));
        }
      } else {
        blocked = true;
      }
    }
    blocked = false;
    // Positive Y:
    ny = y;
    while (!blocked) {
      ny++;
      if (isInsideBoard(new Vector2D(ny, x))) {
        Token bt = board.getToken(ny, x);
        if (hitsRock(new Vector2D(ny, x))) {
          blocked = true;
        } else if (bt.getOwn() == this.getTurn().side()) {
          blocked = true;
        } else if (bt.getOwn() == this.getTurn().otherSide()) {
          sctMovements.add(new Vector2D(ny, x));
          blocked = true;
        } else {
          sctMovements.add(new Vector2D(ny, x));
        }
      } else {
        blocked = true;
      }
    }
    blocked = false;
    // Negative X:
    int nx = x;
    while (!blocked) {
      nx--;
      if (isInsideBoard(new Vector2D(y, nx))) {
        Token bt = board.getToken(y, nx);
        if (hitsRock(new Vector2D(y, nx))) {
          blocked = true;
        } else if (bt.getOwn() == this.getTurn().side()) {
          blocked = true;
        } else if (bt.getOwn() == this.getTurn().otherSide()) {
          sctMovements.add(new Vector2D(y, nx));
          blocked = true;
        } else {
          sctMovements.add(new Vector2D(y, nx));
        }
      } else {
        blocked = true;
      }
    }
    blocked = false;
    // Positive X:
    nx = x;
    while (!blocked) {
      nx++;
      if (isInsideBoard(new Vector2D(y, nx))) {
        Token bt = board.getToken(y, nx);
        if (hitsRock(new Vector2D(y, nx))) {
          blocked = true;
        } else if (bt.getOwn() == this.getTurn().side()) {
          blocked = true;
        } else if (bt.getOwn() == this.getTurn().otherSide()) {
          sctMovements.add(new Vector2D(y, nx));
          blocked = true;
        } else {
          sctMovements.add(new Vector2D(y, nx));
        }
      } else {
        blocked = true;
      }
    }

    return sctMovements;
  }