Exemplo n.º 1
0
  @Override
  public int compare(Tile arg0, Tile arg1) {
    /** Folosim distanta Manhattan * */
    int x = 10 * (Math.abs(arg0.col() - reference.col()) + Math.abs(arg0.row() - reference.row()));
    int y = 10 * (Math.abs(arg1.col() - reference.col()) + Math.abs(arg1.row() - reference.row()));

    return x - y;
  }
Exemplo n.º 2
0
 public int manhattanDist(Tile tile2) {
   int d1, d2;
   d1 = Math.abs(row - tile2.row());
   d2 = Math.abs(col - tile2.col());
   d1 = d1 < (Ants.rows() - d1) ? d1 : (Ants.rows() - d1);
   d2 = d2 < (Ants.cols() - d2) ? d2 : (Ants.cols() - d2);
   return (d1 + d2);
 }