Advertisement
horozov86

pawn wars

Jun 13th, 2023
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. from math import ceil
  2. SIZE = 8
  3. matrix = []
  4. w_row = 0
  5. w_col = 0
  6. b_row = 0
  7. b_col = 0
  8.  
  9. matrix_board = []
  10. for board_row in range(SIZE, 0, -1):
  11.     row_element = [f'{chr(97 + x)}{board_row}' for x in range(SIZE)]
  12.     matrix_board.append(row_element)
  13.  
  14. for row in range(SIZE):
  15.     inner_list = input().split()
  16.     for col in range(SIZE):
  17.         if inner_list[col] == 'w':
  18.             w_row = row
  19.             w_col = col
  20.  
  21.         if inner_list[col] == 'b':
  22.             b_row = row
  23.             b_col = col
  24.     matrix.append(inner_list)
  25.  
  26. if not abs(b_col - w_col) == 1:
  27.     if (SIZE - b_row) > w_row:
  28.         print(f"Game over! White pawn is promoted to a queen at {matrix_board[SIZE - SIZE][w_col]}.")
  29.     else:
  30.         print(f"Game over! Black pawn is promoted to a queen at {matrix_board[SIZE - 1][b_col]}.")
  31.  
  32. else:
  33.     if abs(b_row - w_row) % 2 == 0:
  34.         print(f"Game over! Black win, capture on {matrix_board[b_row + ceil(abs(b_row - w_row) / 2)][w_col]}.")
  35.     else:
  36.         print(f"Game over! White win, capture on {matrix_board[w_row - ceil(abs(b_row - w_row) / 2)][b_col]}.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement