forked from YoungHaKim/berkeley_python_project_1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbishop.py
30 lines (24 loc) · 1.27 KB
/
bishop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from chessPiece import chessPiece
class bishop():
"""Computes all possible moves for bishop pieces"""
@staticmethod
def getNormalMoves(piece, position: tuple, board: list):
"""returns list of potential non-capture moves from a given position"""
row, col = position
potential_moves = []
chessPiece.moveUpdate(-1, -1, row, col, board, potential_moves, 8)
chessPiece.moveUpdate(1, 1, row, col, board, potential_moves, 8)
chessPiece.moveUpdate(-1, 1, row, col, board, potential_moves, 8)
chessPiece.moveUpdate(1, -1, row, col, board, potential_moves, 8)
return potential_moves
@staticmethod
def getCaptureMoves(piece, position: tuple, board: list):
"""returns list of potential capture moves from a given position"""
color_sign = 1 if piece == 'B' else -1
row, col = position
potential_moves = []
chessPiece.captureUpdate(1, 1, color_sign, row, col, board, potential_moves, 8)
chessPiece.captureUpdate(1, -1, color_sign, row, col, board, potential_moves, 8)
chessPiece.captureUpdate(-1, 1, color_sign, row, col, board, potential_moves, 8)
chessPiece.captureUpdate(-1, -1, color_sign, row, col, board, potential_moves, 8)
return potential_moves