### Question:
MapTilePathModel extends FeatureAbstract implements MapTilePath { private CoordTile getClosestAvailableTile(Pathfindable mover, int stx, int sty, int stw, int sth, int dtx, int dty, int dtw, int dth, int radius) { int closestX = 0; int closestY = 0; double dist = Double.MAX_VALUE; int size = 1; boolean found = false; while (!found) { for (int tx = stx - size; tx <= stx + size; tx++) { for (int ty = sty - size; ty <= sty + size; ty++) { if (isAreaAvailable(mover, tx, ty, stw, sth, null)) { final double d = UtilMath.getDistance(tx, ty, stw, sth, dtx, dty, dtw, dth); if (d < dist) { dist = d; closestX = tx; closestY = ty; found = true; } } } } size++; if (size >= radius) { return null; } } return new CoordTile(closestX, closestY); } MapTilePathModel(); @Override void prepare(FeatureProvider provider); @Override void loadPathfinding(Media pathfindingConfig); @Override void addObjectId(int tx, int ty, Integer id); @Override void removeObjectId(int tx, int ty, Integer id); @Override Set<Integer> getObjectsId(int tx, int ty); @Override Tile getTile(Tiled tiled); @Override String getCategory(Tile tile); @Override boolean isBlocked(Pathfindable mover, int tx, int ty, boolean ignoreObjectsId); @Override double getCost(Pathfindable mover, int tx, int ty); @Override Collection<String> getCategories(); @Override CoordTile getFreeTileAround(Pathfindable mover, Tiled tiled); @Override CoordTile getFreeTileAround(Pathfindable mover, Tiled tiled, int radius); @Override CoordTile getFreeTileAround(Pathfindable mover, int tx, int ty, int tw, int th, int radius); @Override CoordTile getClosestAvailableTile(Pathfindable mover, Tiled to, int radius); @Override CoordTile getClosestAvailableTile(Pathfindable mover, int stx, int sty, int dtx, int dty, int radius); @Override boolean isAreaAvailable(Area area, Pathfindable mover); @Override boolean isAreaAvailable(Pathfindable mover, int tx, int ty, int tw, int th, Integer ignoreObjectId);  }### Answer:
@Test void testGetClosestTileAvailable() { final Pathfindable pathfindable = createObject(); final TileArea tile = new TileArea(1, 2, 1, 1); CoordTile coord = mapPath.getClosestAvailableTile(pathfindable, tile, 6); assertEquals(1, coord.getX()); assertEquals(1, coord.getY()); coord = mapPath.getClosestAvailableTile(pathfindable, 1, 2, 2, 3, 6); assertEquals(2, coord.getX()); assertEquals(3, coord.getY()); }