-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboard.py
More file actions
30 lines (26 loc) · 732 Bytes
/
board.py
File metadata and controls
30 lines (26 loc) · 732 Bytes
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
# chess_board.py
BOARD_SIZE = 8
SQUARE_SIZE = 80
LIGHT_COLOR = '#6586A7'
DARK_COLOR = '#EBEBEB'
HIGHLIGHT_COLOR = '#FF8C00'
def initial_board():
board = []
for i in range(8):
row = []
for j in range(8):
row.append(None)
board.append(row)
# Black pieces
board[0] = ['r','n','b','q','k','b','n','r']
board[1] = ['p','p','p','p','p','p','p','p']
# White pieces
board[6] = ['P','P','P','P','P','P','P','P']
board[7] = ['R','N','B','Q','K','B','N','R']
return board
def inside(r, c):
return 0 <= r < 8 and 0 <= c < 8
def is_white(piece):
return piece is not None and piece.isupper()
def is_black(piece):
return piece is not None and piece.islower()