Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. def draw_board(self, game):
  2. matrix = [["| |" for _ in range(8)] for _ in range(8)]
  3. for piece in game.board.pieces:
  4. if not piece.captured:
  5. if piece.player == 1:
  6. if piece.king:
  7. symbol = "|B|"
  8. else:
  9. symbol = "|b|"
  10. else:
  11. if piece.king:
  12. symbol = "|W|"
  13. else:
  14. symbol = "|w|"
  15.  
  16. element = (2 * piece.position - 1) % 8
  17. pos = piece.position // 4
  18. if piece.position % 4 == 0:
  19. pos -= 1
  20. if pos % 2 != 0:
  21. element -= 1
  22. matrix[pos][element] = symbol
  23.  
  24. for i in range(0, 8):
  25. for j in range(0, 8):
  26. print(matrix[i][j], end=" ")
  27. print(" ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement