Falguni commited on
Commit
790e820
·
1 Parent(s): e128c52

Render board for appropriate side

Browse files
Files changed (1) hide show
  1. src/thinksqure_engine.py +19 -3
src/thinksqure_engine.py CHANGED
@@ -274,7 +274,12 @@ class ThinkSquareEngine:
274
  fen = chess.STARTING_FEN
275
 
276
  board = chess.Board(fen)
277
- ascii_representation = str(board)
 
 
 
 
 
278
 
279
  return ascii_representation
280
 
@@ -284,7 +289,13 @@ class ThinkSquareEngine:
284
  fen = chess.STARTING_FEN
285
 
286
  board = chess.Board(fen)
287
- svg = chess.svg.board(board=board, size=400, coordinates=True)
 
 
 
 
 
 
288
  return svg
289
 
290
  @staticmethod
@@ -293,6 +304,11 @@ class ThinkSquareEngine:
293
  fen = chess.STARTING_FEN
294
 
295
  board = chess.Board(fen)
296
- unicode_representation = board.unicode(invert_color=False)
 
 
 
 
 
297
 
298
  return unicode_representation
 
274
  fen = chess.STARTING_FEN
275
 
276
  board = chess.Board(fen)
277
+
278
+ display_board = board.copy()
279
+ if board.turn == chess.BLACK:
280
+ display_board = display_board.mirror()
281
+
282
+ ascii_representation = str(display_board)
283
 
284
  return ascii_representation
285
 
 
289
  fen = chess.STARTING_FEN
290
 
291
  board = chess.Board(fen)
292
+
293
+ display_board = board.copy()
294
+ if board.turn == chess.BLACK:
295
+ display_board = display_board.mirror()
296
+
297
+ svg = chess.svg.board(board=display_board, size=400, coordinates=True)
298
+
299
  return svg
300
 
301
  @staticmethod
 
304
  fen = chess.STARTING_FEN
305
 
306
  board = chess.Board(fen)
307
+
308
+ display_board = board.copy()
309
+ if board.turn == chess.BLACK:
310
+ display_board = display_board.mirror()
311
+
312
+ unicode_representation = display_board.unicode(invert_color=False)
313
 
314
  return unicode_representation