- A* działa
- Wyszukiwanie zmienione na tree search - Do poprawki to żeby było widać ktoki traktora(na razie widać tylko w konsoli)
This commit is contained in:
parent
34039542bd
commit
3375a8adca
@ -56,7 +56,7 @@ class activities:
|
||||
|
||||
def activity_val(self,value):
|
||||
self.mode = value
|
||||
print(self.mode)
|
||||
print("Tryb: "+ str(self.modes[self.mode]))
|
||||
|
||||
def activity_get_value(self):
|
||||
return self.mode
|
||||
|
37
functions.py
37
functions.py
@ -10,18 +10,6 @@ def quit():
|
||||
pygame.quit()
|
||||
sys.exit()
|
||||
|
||||
class Node():
|
||||
def __init__(self, parent=None, position=None):
|
||||
self.parent = parent
|
||||
self.position = position
|
||||
|
||||
self.g = 0
|
||||
self.h = 0
|
||||
self.f = 0
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.position == other.position
|
||||
|
||||
def pressed(key, traktor_poz):
|
||||
if key[K_d]:
|
||||
return(move_right())
|
||||
@ -133,8 +121,6 @@ def pathfinding():
|
||||
avaiable_value = [0,1,4,5]
|
||||
elif activity == 3:
|
||||
avaiable_value = [8]
|
||||
opened = []
|
||||
closed = []
|
||||
start_position = [int(((config.TRAKTOR_POZ[1]-5)/70)-1), int(((config.TRAKTOR_POZ[0]-5)/70)-1)]
|
||||
end_point = search(start_position,avaiable_value)
|
||||
if start_position == end_point:
|
||||
@ -152,7 +138,7 @@ def pathfinding():
|
||||
elif i[1]< poz[1]:
|
||||
move_left()
|
||||
pygame.display.update()
|
||||
time.sleep(2)
|
||||
time.sleep(0.2)
|
||||
work([int(((config.TRAKTOR_POZ[1]-5)/70)-1), int(((config.TRAKTOR_POZ[0]-5)/70)-1)])
|
||||
|
||||
def a_star(start, end):
|
||||
@ -188,19 +174,16 @@ def a_star(start, end):
|
||||
|
||||
return finall_path
|
||||
|
||||
closed = []
|
||||
def search(point,values):
|
||||
global closed
|
||||
if config.POLE_STAN[point[0],point[1]] in values:
|
||||
closed = []
|
||||
return point
|
||||
def search(start,value):
|
||||
visited = [start]
|
||||
while visited:
|
||||
if config.POLE_STAN[visited[0][0],visited[0][1]] in value:
|
||||
print("Znaleziono pole: "+str(visited[0]))
|
||||
return visited[0]
|
||||
else:
|
||||
closed.append(point)
|
||||
childs = points(point)
|
||||
while childs:
|
||||
child = childs.pop()
|
||||
if child not in closed:
|
||||
return search(child,values)
|
||||
for i in points(visited[0]):
|
||||
visited.append(i)
|
||||
del visited[0]
|
||||
|
||||
|
||||
def points(point):
|
||||
|
Loading…
Reference in New Issue
Block a user