-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bishop.py
111 lines (99 loc) · 2.14 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#location has to be the index of the list board
def Bishop(piece, location, board, active_indx):
this = [] #All possible places that can be moved to
S_E = [] #Movement DOWN + RIGHT
N_E = [] #Movement UP + RIGHT
S_W = [] #Movement DOWN + LEFT
N_W = [] #Movement UP + LEFT
if piece > 0:
i = 1
while True:
SE_loc = location + i * 10
if board[SE_loc] > 0 or SE_loc not in active_indx:
break
elif board[SE_loc] < 0:
S_E.append(SE_loc)
break
S_E.append(SE_loc)
i += 1
j = 1
while True:
NW_loc = location - j * 10
if board[NW_loc] > 0 or NW_loc not in active_indx:
break
elif board[NW_loc] < 0:
N_W.append(NW_loc)
break
N_W.append(NW_loc)
j += 1
k = 1
while True:
NE_loc = location - k * 8
if board[NE_loc] > 0 or NE_loc not in active_indx:
break
elif board[NE_loc] < 0:
N_E.append(NE_loc)
break
N_E.append(NE_loc)
k += 1
l = 1
while True:
SW_loc = location + l * 8
if board[SW_loc] > 0 or SW_loc not in active_indx:
break
elif board[SW_loc] < 0:
S_W.append(SW_loc)
break
S_W.append(SW_loc)
l += 1
this.extend(S_E)
this.extend(N_E)
this.extend(S_W)
this.extend(N_W)
return this
elif piece < 0:
i = 1
while True:
SE_loc = location + i * 10
if board[SE_loc] < 0 or SE_loc not in active_indx:
break
elif board[SE_loc] > 0:
S_E.append(SE_loc)
break
S_E.append(SE_loc)
i += 1
j = 1
while True:
NW_loc = location - j * 10
if board[NW_loc] < 0 or NW_loc not in active_indx:
break
elif board[NW_loc] > 0:
N_W.append(NW_loc)
break
N_W.append(NW_loc)
j += 1
k = 1
while True:
NE_loc = location - k * 8
if board[NE_loc] < 0 or NE_loc not in active_indx:
break
elif board[NE_loc] > 0:
N_E.append(NE_loc)
break
N_E.append(NE_loc)
k += 1
l = 1
while True:
SW_loc = location + l * 8
if board[SW_loc] < 0 or SW_loc not in active_indx:
break
elif board[SW_loc] >0:
S_W.append(SW_loc)
break
S_W.append(SW_loc)
l += 1
this.extend(S_E)
this.extend(N_E)
this.extend(S_W)
this.extend(N_W)
return this