Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def proverka(cell):
- if 1 <= cell[0] <= 8 and 1 <= cell[1] <= 8:
- return True
- return False
- def obrabotka1(cell):
- letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
- x, y = list(cell)
- for i in range(8):
- if x == letters[i]:
- return i + 1, int(y)
- def obrabotka2(cell):
- letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
- return letters[cell[0] - 1] + str(cell[1])
- def possibleTurns(cell):
- cell = obrabotka1(cell)
- turns = []
- if proverka((cell[0] - 1, cell[1] - 2)):
- turns.append(obrabotka2((cell[0] - 1, cell[1] - 2)))
- if proverka((cell[0] + 1, cell[1] + 2)):
- turns.append(obrabotka2((cell[0] + 1, cell[1] + 2)))
- if proverka((cell[0] - 1, cell[1] + 2)):
- turns.append(obrabotka2((cell[0] - 1, cell[1] + 2)))
- if proverka((cell[0] + 1, cell[1] - 2)):
- turns.append(obrabotka2((cell[0] + 1, cell[1] - 2)))
- if proverka((cell[0] - 2, cell[1] - 1)):
- turns.append(obrabotka2((cell[0] - 2, cell[1] - 1)))
- if proverka((cell[0] + 2, cell[1] + 1)):
- turns.append(obrabotka2((cell[0] + 2, cell[1] + 1)))
- if proverka((cell[0] - 2, cell[1] + 1)):
- turns.append(obrabotka2((cell[0] - 2, cell[1] + 1)))
- if proverka((cell[0] + 2, cell[1] - 1)):
- turns.append(obrabotka2((cell[0] + 2, cell[1] - 1)))
- return sorted(turns)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement