Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Mar 29th, 2020 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def dvizenje_na_covece_desno(x, y, precki):
  2.     if x < 10 and [x+1, y] not in precki:
  3.         x += 1
  4.     return x
  5. def dvizenje_na_covece_levo(x, y, precki):
  6.     if x > 0 and [x-1, y] not in precki:
  7.         x -= 1
  8.     return x
  9. def dvizenje_na_covece_pravo(x, y, precki):
  10.     if y < 10 and [x, y+1] not in precki:
  11.         y += 1
  12.     return y
  13. def dvizenje_na_covece_nazad(x, y, precki):
  14.     if y > 0 and [x, y-1] not in precki:
  15.         y -= 1
  16.     return y
  17.  
  18.  
  19. class Covece(Problem):
  20.     def __init__(self, precki, initial, goal=None):
  21.         super().__init__(initial, goal)
  22.         self.precki = precki
  23.  
  24.  
  25.     def successor(self, state):
  26.  
  27.         successors = dict()
  28.  
  29.         covece_x = state[0]
  30.         covece_y = state[1]
  31.         tocki_pozicija = state[2]
  32.         y_new = dvizenje_na_covece_pravo(covece_x, covece_y, self.precki)
  33.         if y_new != covece_y:
  34.             successors['ProdolzhiPravo'] = (covece_x, y_new,
  35.                                             tuple([t for t in tocki_pozicija if t[0] != y_new or t[1] != covece_x]))
  36.         y_new = dvizenje_na_covece_nazad(covece_x, covece_y, self.precki)
  37.         if y_new != covece_y:
  38.             successors['ProdolzhiNazad'] = (covece_x, y_new,
  39.                                             tuple([t for t in tocki_pozicija if t[0] != y_new or t[1] != covece_x]))
  40.         x_new = dvizenje_na_covece_levo(covece_x, covece_y, self.precki)
  41.         if x_new != covece_x:
  42.             successors['SvrtiLevo'] = (x_new, covece_y,
  43.                                         tuple([t for t in tocki_pozicija if t[0] != x_new or t[1] != covece_y]))
  44.         x_new = dvizenje_na_covece_desno(covece_x, covece_y, self.precki)
  45.         if x_new != covece_x:
  46.             successors['SvrtiDesno'] = (x_new, covece_y,
  47.                                         tuple([t for t in tocki_pozicija if t[0] != x_new or t[1] != covece_y]))
  48.  
  49.         return successors
  50.  
  51.     def actions(self, state):
  52.         return self.successor(state).keys()
  53.  
  54.     def result(self, state, action):
  55.         return self.successor(state)[action]
  56.  
  57.     def goal_test(self, state):
  58.         #prazna torka od tocki
  59.         return len(state[-1]) == 0
  60.  
  61.  
  62. if __name__ == '__main__':
  63.     #sekogas fiksna precki lista
  64.     precki_lista = [[9, 7], [8, 8], [9, 8], [8, 7], [6, 9], [4, 5], [6, 1],
  65.                     [8, 4], [0, 6], [4, 6], [5, 1], [9, 4], [0, 8], [4, 7],
  66.                     [4, 1], [1, 2], [0, 9], [3, 6], [8, 1], [1, 3], [1, 9],
  67.                     [5, 6], [6, 2], [1, 4], [2, 9], [3, 9]]
  68.     covece_x = int(input())
  69.     covece_y = int(input())
  70.     nasokaNaIgracot = str(input())
  71.     brojNaTocki = int(input())
  72.     pomosnaLista =[]
  73.     for x in range(brojNaTocki):
  74.         string = input().split(",")
  75.         pomosnaLista1 = []
  76.         pomosnaLista1.append(int(string[0]))
  77.         pomosnaLista1.append(int(string[1]))
  78.         pomosnaLista.append((tuple(pomosnaLista1)))
  79.     tocki_torka = tuple(pomosnaLista)
  80.     covece = Covece(precki_lista, (covece_x, covece_y, tocki_torka))
  81.     print(breadth_first_graph_search(covece).solution())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top