Skip to content

Commit 1909f1c

Browse files
committed
Code golf board.unicode()
1 parent d783fa0 commit 1909f1c

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

chess/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,10 +1229,8 @@ def unicode(self, *, invert_color: bool = False, borders: bool = False, empty_sq
12291229
:param invert_color: Invert color of the Unicode pieces.
12301230
:param borders: Show borders and a coordinate margin.
12311231
"""
1232-
board = self.copy()
12331232
builder = []
1234-
indexes = range(7, -1, -1) if orientation else range(8)
1235-
for rank_index in indexes:
1233+
for rank_index in (range(7, -1, -1) if orientation else range(8)):
12361234
if borders:
12371235
builder.append(" ")
12381236
builder.append("-" * 17)
@@ -1249,7 +1247,7 @@ def unicode(self, *, invert_color: bool = False, borders: bool = False, empty_sq
12491247
elif file_index > 0:
12501248
builder.append(" ")
12511249

1252-
piece = board.piece_at(square_index)
1250+
piece = self.piece_at(square_index)
12531251

12541252
if piece:
12551253
builder.append(piece.unicode_symbol(invert_color=invert_color))
@@ -1259,7 +1257,7 @@ def unicode(self, *, invert_color: bool = False, borders: bool = False, empty_sq
12591257
if borders:
12601258
builder.append("|")
12611259

1262-
if borders or (rank_index > 0 and orientation) or (rank_index < 7 and not orientation):
1260+
if borders or (rank_index > 0 if orientation else rank_index < 7):
12631261
builder.append("\n")
12641262

12651263
if borders:

0 commit comments

Comments
 (0)