public Resource getNearestResource(Tile tile, Dude dude) {

		int x = tile.getX();
		int y = tile.getY();
		int bestSquaredDistance = Integer.MAX_VALUE;
		Resource bestResource = null;

		for (Resource r : resources) {
			if (!dude.canMine(r))
				continue;
			Tile restile = getTile(r.getX(), r.getY());
			if (restile.getDude() != null && restile.getDude() != dude)
				continue;
			int squaredDistance = (r.getX() - x) * (r.getX() - x)
					+ (r.getY() - y) * (r.getY() - y);

			if (squaredDistance < bestSquaredDistance) {
				if (!getLogic().findRoute(tile, getTile(r.getX(), r.getY()),
						dude).isEmpty()
						|| getTile(dude.getX(), dude.getY()) == tile) {
					bestSquaredDistance = squaredDistance;
					bestResource = r;
				}
			}
		}
		return bestResource;
	}