From 8f00d5f087beeab4d02fead860db36486613861b Mon Sep 17 00:00:00 2001 From: ddamiankowalski Date: Sun, 3 Apr 2022 21:53:24 +0200 Subject: [PATCH] DZIALAJACA WERSJA --- board | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/board b/board index 8702df9..9da2d6e 100644 --- a/board +++ b/board @@ -120,22 +120,22 @@ def checkGoal(fieldList, gridNum): currentField.visited = True ## JEZELI DANE POLE NIE ZOSTALO ODWIEDZONE, TO DODAJEMY DO KOLEJKI WSZYSTKIE POLA OBOK I LECIMY DALEJ - if currentIndex + 15 <= 224: + if currentIndex + 15 <= 224 and fieldList[currentIndex + 15].visited == False: fieldQueue.append(fieldList[currentIndex + 15]) fieldList[currentIndex + 15].parent = fieldList[currentIndex] print("APPENDED DOWN!!!") fieldList[currentIndex + 15].printXandY() - if currentIndex - 15 > -1: + if currentIndex - 15 > -1 and fieldList[currentIndex - 15].visited == False: fieldQueue.append(fieldList[currentIndex - 15]) fieldList[currentIndex - 15].parent = fieldList[currentIndex] print("APPENDED UP!!!") fieldList[currentIndex - 15].printXandY() - if (currentIndex + 1) % 15 != 0: + if (currentIndex + 1) % 15 != 0 and fieldList[currentIndex + 1].visited == False: fieldQueue.append(fieldList[currentIndex + 1]) fieldList[currentIndex + 1].parent = fieldList[currentIndex] print("APPENDED RIGHT!!!") fieldList[currentIndex + 1].printXandY() - if (currentIndex - 1) % 15 != 14 or not currentIndex - 1 < 0: + if (currentIndex - 1) % 15 != 14 and not currentIndex - 1 < 0 and fieldList[currentIndex - 1].visited == False: fieldQueue.append(fieldList[currentIndex - 1]) fieldList[currentIndex - 1].parent = fieldList[currentIndex] print("APPENDED LEFT!!!") @@ -145,8 +145,8 @@ if __name__ == '__main__': pygame.init() #inicjalizacja modułów, na razie niepotrzebna #Tworzymy nowego playera, czy tam agenta - agent = Object("smieciarka", 5, 5) - target = Object("cel", 1, 1) + agent = Object("smieciarka", 15, 15) + target = Object("cel", 1, 2) objectArray.append(agent) objectArray.append(target) @@ -164,10 +164,22 @@ if __name__ == '__main__': newField.printXandY() fields.append(newField) - result = startQueue(objectArray[0].xPos, objectArray[0].yPos, fields, 15) + result = startQueue(objectArray[0].xPos - 1, objectArray[0].yPos - 1, fields, 15) - print("RESULT IS: ") + + print("RESULT TARGET IS: ") result.printXandY() + print("RESULT TRUCK IS: ") + print("X: " + str(objectArray[0].xPos - 1) + " Y: " + str(objectArray[0].yPos - 1)) + + + result_parent = result.parent + + print("CHECKING PARENTS ===========") + ## FINDING THE MAIN PARENT + while input("enter message") != "finish": + result_parent.printXandY() + result_parent = result_parent.parent while 1: c = (255, 255, 255) #tymczasowy kolor tła - do usunięcia, jak już będzie zdjęcie