added tile distance calculation.