From 153a4e8ac583119533156901948bf388e9945b3a Mon Sep 17 00:00:00 2001 From: Rob Sheppard Date: Thu, 17 Aug 2023 00:02:14 -0500 Subject: [PATCH] tweaked doc strings in init chess file --- chess/__init__.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/chess/__init__.py b/chess/__init__.py index 65719fd5c..70771d987 100644 --- a/chess/__init__.py +++ b/chess/__init__.py @@ -181,37 +181,36 @@ def parse_square(name: str) -> Square: return SQUARE_NAMES.index(name) def square_name(square: Square) -> str: - """Gets the name of the square, like ``a3``.""" + """Takes a square as a parameter and returns the name of the square as a string --e.g. ``a3``.""" return SQUARE_NAMES[square] def square(file_index: int, rank_index: int) -> Square: - """Gets a square number by file and rank index.""" + """Takes a file index(int) and rank index(int) as parameters and returns a square number.""" return rank_index * 8 + file_index def square_file(square: Square) -> int: - """Gets the file index of the square where ``0`` is the a-file.""" + """Takes a square as a parameter and returns the file index of the square as an int + where ``0`` is the a-file.""" return square & 7 def square_rank(square: Square) -> int: - """Gets the rank index of the square where ``0`` is the first rank.""" + """Takes a square as a parameter and returns the rank index of the square as an int + where ``0`` is the first rank.""" return square >> 3 def square_distance(a: Square, b: Square) -> int: - """ - Gets the Chebyshev distance (i.e., the number of king steps) from square *a* to *b*. - """ + """Takes two squares as a parameter and returns the Chebyshev distance (i.e.the number + of king steps) from square *a* to *b* as an integer.""" return max(abs(square_file(a) - square_file(b)), abs(square_rank(a) - square_rank(b))) def square_manhattan_distance(a: Square, b: Square) -> int: - """ - Gets the Manhattan/Taxicab distance (i.e., the number of orthogonal king steps) from square *a* to *b*. - """ + """Takes two squares as a parameter and returns the Manhattan/Taxicab distance (i.e. the + number of orthogonal king steps) from square *a* to *b* as an integer.""" return abs(square_file(a) - square_file(b)) + abs(square_rank(a) - square_rank(b)) def square_knight_distance(a: Square, b: Square) -> int: - """ - Gets the Knight distance (i.e., the number of knight moves) from square *a* to *b*. - """ + """Takes two squares as parameters and returns the Knight distance (i.e. the number of + knight moves) from square *a* to *b* as an integer.""" dx = abs(square_file(a) - square_file(b)) dy = abs(square_rank(a) - square_rank(b))