Konwertowanie współrzędnych na akcje - praca w toku...
This commit is contained in:
parent
9049316049
commit
20577797fb
69
actions.py
Normal file
69
actions.py
Normal file
@ -0,0 +1,69 @@
|
||||
#Funkcja konwertujaca wspolrzedne nastepnego pola do odwiedzenia
|
||||
#na kolejke akcji do wykonania
|
||||
|
||||
# tl - turn left, tr - turn right, fwd - forward, op - open
|
||||
#queue - kolejka akcji do zrobienia, pole klasy Player
|
||||
#path - kolejka pol do odwiedzenia, pole klasy Player
|
||||
|
||||
#pole to element wziety z kolejki path
|
||||
|
||||
def actionPlanner(self,pole):
|
||||
x0 = self.pos[0]
|
||||
y0 = self.pos[1]
|
||||
x = pole[0]
|
||||
y = pole[1]
|
||||
if (x > x0):
|
||||
if (self.direction == 1):
|
||||
self.queue.insert("fwd")
|
||||
elif (self.direction == 0):
|
||||
self.queue.insert("tr")
|
||||
self.queue.insert("fwd")
|
||||
elif (self.direction == 2):
|
||||
self.queue.insert("tl")
|
||||
self.queue.insert("fwd")
|
||||
else:
|
||||
self.queue.insert("tr")
|
||||
self.queue.insert("tr")
|
||||
self.queue.insert("fwd")
|
||||
elif (x < x0):
|
||||
if (self.direction == 3):
|
||||
self.queue.insert("fwd")
|
||||
elif (self.direction == 0):
|
||||
self.queue.insert("tl")
|
||||
self.queue.insert("fwd")
|
||||
elif (self.direction == 2):
|
||||
self.queue.insert("tr")
|
||||
self.queue.insert("fwd")
|
||||
else:
|
||||
self.queue.insert("tr")
|
||||
self.queue.insert("tr")
|
||||
self.queue.insert("fwd")
|
||||
else:
|
||||
if (y > y0):
|
||||
if (self.direction == 0):
|
||||
self.queue.insert("fwd")
|
||||
elif (self.direction == 1):
|
||||
self.queue.insert("tl")
|
||||
self.queue.insert("fwd")
|
||||
elif (self.direction == 3):
|
||||
self.queue.insert("tr")
|
||||
self.queue.insert("fwd")
|
||||
else:
|
||||
self.queue.insert("tr")
|
||||
self.queue.insert("tr")
|
||||
self.queue.insert("fwd")
|
||||
else:
|
||||
if (self.direction == 2):
|
||||
self.queue.insert("fwd")
|
||||
elif (self.direction == 3):
|
||||
self.queue.insert("tl")
|
||||
self.queue.insert("fwd")
|
||||
elif (self.direction == 1):
|
||||
self.queue.insert("tr")
|
||||
self.queue.insert("fwd")
|
||||
else:
|
||||
self.queue.insert("tr")
|
||||
self.queue.insert("tr")
|
||||
self.queue.insert("fwd")
|
||||
if (self.path.empty()):
|
||||
self.queue.insert("op")
|
Loading…
Reference in New Issue
Block a user