Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- '''def make_choice(x, y, field):
- x_size = len(field)
- y_size = len(field[0])
- for searcher_x in range(1, x_size - 2):
- for searcher_y in range(1, y_size - 2):
- if field[searcher_x][searcher_y] != 0:
- destroy_chord_x = searcher_x
- destroy_chord_y = searcher_y
- while x != destroy_chord_x or y != destroy_chord_y:
- for searcher_x in range(1, x_size - 2):
- for searcer_y in range(1, y_size - 2):
- if field[searcher_x][searcher_y] != 0:
- destroy_chord_x = searcher_x
- destroy_chord_y = searcher_y
- global x_destination
- global y_destination
- if searcher_x > x:
- x_destination = 1 # вниз
- else:
- x_destination = 0 # вверх
- destroy_chord_y = searcher_y
- if searcher_y > y:
- y_destination = 1 # вправо
- else:
- y_destination = 0 # влево
- hunt_x_or_y = random.choice(["x", "y"])
- if hunt_x_or_y == "x" and x_destination == 1:
- return "go_down"
- if hunt_x_or_y == "x" and x_destination == 0:
- return "go_up"
- if hunt_x_or_y == "y" and y_destination == 1:
- return "go_right"
- if hunt_x_or_y == "y" and y_destination == 0:
- return "go_left"'''
- if field[x][y]["life"] < 8:
- for i in range(0, x - 1):
- if field[i][y] != 0:
- return "go_down"
- for i in range(x + 1, x_size):
- if field[i][y] != 0:
- return "go_up"
- for i in range(0, y - 1):
- if field[x][i] != 0:
- return "go_left"
- for i in range(y + 1, y_size):
- if field[x][i] != 0:
- return "go_right"
- for i in range(0, x - 1):
- if field[i][y] != 0:
- return "fire_left"
- for i in range(x + 1, x_size):
- if field[i][y] != 0:
- return "fire_right"
- for i in range(0, y - 1):
- if field[x][i] != 0:
- return "fire_up"
- for i in range(y + 1, y_size):
- if field[x][i] != 0:
- return "fire_down"
- if x < x_size - 1:
- return "go_right"
- if y < y_size - 1:
- return "go_down"
- return random.choice(["fire_up", "fire_left"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement