Naming conventions

This commit is contained in:
Norbert Litkowski 2019-04-29 12:45:56 +01:00
parent 12354f8d6e
commit a9c0ae6a10
2 changed files with 11 additions and 10 deletions

View File

@ -14,7 +14,7 @@ class AStarNode():
return self.position == other.position
def APath(table, start, end):
def a_path(table, start, end):
# Create start and end node
start_node = AStarNode(None, start)
@ -32,7 +32,7 @@ def APath(table, start, end):
i = 0
while len(open_list) > 0:
print(i)
i=i+1
i = i + 1
current_node = open_list[0]
current_index = 0
@ -78,21 +78,23 @@ def APath(table, start, end):
for child in children:
def InClosedlist(child: AStarNode):
def in_closed_list(child: AStarNode):
for closed_child in closed_list:
if child.position == closed_child.position:
return True
return False
def InOpenlist(child: AStarNode):
def in_open_list(child: AStarNode):
for open_node in open_list:
if child == open_node:
return True
return False
# Child is on the closed list
if InClosedlist(child)==True:
if in_closed_list(child)==True:
continue
child.g = current_node.g + 1
@ -100,7 +102,7 @@ def APath(table, start, end):
child.f = child.g + child.h
# Child is already in the open list
if InOpenlist(child)==True:
if in_open_list(child):
continue
open_list.append(child)

View File

@ -1,9 +1,8 @@
import pygame as pg
import numpy as np
import random
from UI.grid import Grid, Node
from UI.Apath import APath
from UI.Grid import Grid, Node
from UI.Apath import a_path
class Window():
@ -55,7 +54,7 @@ class Window():
#copy table
array = [[self.grid.table[col][row] for row in range(cols)] for col in range(rows)]
path = APath(array,(start[0],start[1]),(end[0],end[1]))
path = a_path(array,(start[0],start[1]),(end[0],end[1]))
print("Path:",path)
#draw movement of garbage truck