Skip to content

Commit 9cc4372

Browse files
committed
Made requested changes
1 parent 59b60ea commit 9cc4372

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

chess/__init__.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,25 +220,18 @@ def square_distance(a: Square, b: Square) -> int:
220220
"""
221221
Gets the Chebyshev distance (i.e., the number of king steps) from square *a* to *b*.
222222
"""
223-
if a == b:
224-
return 0;
225223
return max(abs(square_file(a) - square_file(b)), abs(square_rank(a) - square_rank(b)))
226224

227225
def square_manhattan_distance(a: Square, b: Square) -> int:
228226
"""
229227
Gets the Manhattan/Taxicab distance (i.e., the number of orthogonal king steps) from square *a* to *b*.
230228
"""
231-
if a == b:
232-
return 0;
233229
return abs(square_file(a) - square_file(b)) + abs(square_rank(a) - square_rank(b))
234230

235231
def square_knight_distance(a: Square, b: Square) -> int:
236232
"""
237233
Gets the Knight distance (i.e., the number of knight moves) from square *a* to *b*.
238234
"""
239-
if a == b:
240-
return 0;
241-
242235
dx = abs(square_file(a) - square_file(b))
243236
dy = abs(square_rank(a) - square_rank(b))
244237

@@ -247,7 +240,7 @@ def square_knight_distance(a: Square, b: Square) -> int:
247240
elif dx == dy == 2:
248241
return 4
249242
elif dx == dy == 1:
250-
if 1 << a & BB_CORNERS or 1 << b & BB_CORNERS: # Special case only for corner squares
243+
if BB_SQUARES[a] & BB_CORNERS or BB_SQUARES[b] & BB_CORNERS: # Special case only for corner squares
251244
return 4
252245

253246
m = math.ceil(max(dx / 2, dy / 2, (dx + dy) / 3))

0 commit comments

Comments
 (0)