Advertisement
HellFinger

Bot

Feb 13th, 2017
211
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2.  
  3.  
  4. '''def make_choice(x, y, field):
  5.    x_size = len(field)
  6.    y_size = len(field[0])
  7.    for searcher_x in range(1, x_size - 2):
  8.        for searcher_y in range(1, y_size - 2):
  9.            if field[searcher_x][searcher_y] != 0:
  10.                destroy_chord_x = searcher_x
  11.                destroy_chord_y = searcher_y
  12.    while x != destroy_chord_x or y != destroy_chord_y:
  13.        for searcher_x in range(1, x_size - 2):
  14.            for searcer_y in range(1, y_size - 2):
  15.                if field[searcher_x][searcher_y] != 0:
  16.                    destroy_chord_x = searcher_x
  17.                    destroy_chord_y = searcher_y
  18.                    global x_destination
  19.                    global y_destination
  20.                    if searcher_x > x:
  21.                        x_destination = 1  # вниз
  22.                    else:
  23.                        x_destination = 0  # вверх
  24.                    destroy_chord_y = searcher_y
  25.                    if searcher_y > y:
  26.                        y_destination = 1  # вправо
  27.                    else:
  28.                        y_destination = 0  # влево
  29.        hunt_x_or_y = random.choice(["x", "y"])
  30.        if hunt_x_or_y == "x" and x_destination == 1:
  31.            return "go_down"
  32.        if hunt_x_or_y == "x" and x_destination == 0:
  33.            return "go_up"
  34.        if hunt_x_or_y == "y" and y_destination == 1:
  35.            return "go_right"
  36.        if hunt_x_or_y == "y" and y_destination == 0:
  37.            return "go_left"'''
  38.  
  39.     if field[x][y]["life"] < 8:
  40.         for i in range(0, x - 1):
  41.             if field[i][y] != 0:
  42.                 return "go_down"
  43.         for i in range(x + 1, x_size):
  44.             if field[i][y] != 0:
  45.                 return "go_up"
  46.         for i in range(0, y - 1):
  47.             if field[x][i] != 0:
  48.                 return "go_left"
  49.  
  50.         for i in range(y + 1, y_size):
  51.             if field[x][i] != 0:
  52.                 return "go_right"
  53.  
  54.     for i in range(0, x - 1):
  55.         if field[i][y] != 0:
  56.             return "fire_left"
  57.  
  58.     for i in range(x + 1, x_size):
  59.         if field[i][y] != 0:
  60.             return "fire_right"
  61.  
  62.     for i in range(0, y - 1):
  63.         if field[x][i] != 0:
  64.             return "fire_up"
  65.  
  66.     for i in range(y + 1, y_size):
  67.         if field[x][i] != 0:
  68.             return "fire_down"
  69.  
  70.     if x < x_size - 1:
  71.         return "go_right"
  72.     if y < y_size - 1:
  73.         return "go_down"
  74.  
  75.     return random.choice(["fire_up", "fire_left"])
Advertisement
RAW Paste Data Copied
Advertisement