Fix king protection
This commit is contained in:
10
app.py
10
app.py
@@ -393,8 +393,16 @@ def generate_valid_moves(
|
||||
)
|
||||
if king not in enemy_moves:
|
||||
continue
|
||||
ni = i
|
||||
nj = j
|
||||
if j == sx and i == sy:
|
||||
ni = m.y
|
||||
nj = m.x
|
||||
new_enemy_moves = get_piece_moves(
|
||||
p.value.lower(), fake_board, not is_white, xy_to_pos_safe(j, i)
|
||||
p.value.lower(),
|
||||
fake_board,
|
||||
not is_white,
|
||||
xy_to_pos_safe(nj, ni),
|
||||
)
|
||||
if king in new_enemy_moves:
|
||||
king_safe = False
|
||||
|
||||
Reference in New Issue
Block a user