Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wk, wt, bk = input().split()
- verts = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8}
- wk_h = int(wk[1])
- wk_v = verts[wk[0]]
- wt_h = int(wt[1])
- wt_v = verts[wt[0]]
- bk_h = int(bk[1])
- bk_v = verts[bk[0]]
- def king_attacks(k_h, k_v, target_h, target_v):
- if k_h == target_h and k_v == target_v:
- return False
- return abs(k_h - target_h) <= 1 and abs(k_v - target_v) <= 1
- def tower_attacks(t_h, t_v, wk_h, wk_v, target_h, target_v):
- if t_h == target_h and t_v == target_v:
- return False
- # check horizontal
- if t_h == target_h:
- if wk_h != t_h or ((wk_v < t_v and target_v > t_v) or (wk_v > t_v and target_v < t_v)):
- return True
- else:
- return False
- if t_v == target_v:
- if wk_v != t_v or ((wk_h < t_h and target_h > t_h) or (wk_h > t_h and target_h < t_h)):
- return True
- else:
- return False
- return False
- attacked = tower_attacks(wt_h, wt_v, wk_h, wk_v, bk_h, bk_v)
- # ладья стоит рядом с черным королем
- tower_is_near = (abs(bk_h - wt_h) == 1 and abs(bk_v - wt_v) == 1)
- # король может съесть ладью, если стоит рядом с ней, и ее не защищает (атакует) свой король
- can_eat_tower = tower_is_near and not king_attacks(wk_h, wk_v, wt_h, wt_v)
- def bk_can_move(bk_h, bk_v, wk_h, wk_v, t_h, t_v, target_h, target_v):
- if target_h < 1 or target_v < 1:
- return False
- if abs(target_h - bk_h) > 1 or abs(target_v - bk_v) > 1:
- return False
- if king_attacks(wk_h, wk_v, target_h, target_v):
- return False
- if tower_attacks(t_h, t_v, wk_h, wk_v, target_h, target_v):
- return False
- #if tower_is_near and not can_eat_tower:
- # return False
- return True
- #print(bk_can_move(bk_h, bk_v, wk_h, wk_v, wt_h, wt_v, 4, 1))
- # черный король может сделать ход
- targets = [(bk_h - 1, bk_v - 1),
- (bk_h - 1, bk_v),
- (bk_h - 1, bk_v + 1),
- (bk_h + 1, bk_v - 1),
- (bk_h + 1, bk_v),
- (bk_h + 1, bk_v + 1),
- (bk_h, bk_v - 1),
- #(bk_h, bk_v),
- (bk_h, bk_v + 1)
- ]
- can_move = False
- for target_h, target_v in targets:
- if bk_can_move(bk_h, bk_v, wk_h, wk_v, wt_h, wt_v, target_h, target_v):
- can_move = True
- break
- if can_move is False:
- can_move = can_eat_tower
- if king_attacks(wk_h, wk_v, bk_h, bk_v):
- print('Strange')
- else:
- if can_move and not attacked:
- print('Normal')
- if can_move and attacked:
- print('Check')
- if not can_move and not attacked:
- print('Stalemate')
- if not can_move and attacked:
- print('Checkmate')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement