drzewo_wiki #18

Merged
s473561 merged 5 commits from drzewo_wiki into master 2023-05-29 13:28:33 +02:00
7 changed files with 51 additions and 22 deletions
Showing only changes of commit 01e3724d8e - Show all commits

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -16,8 +16,10 @@ icon = pygame.image.load('images/icon.png')
pygame.display.set_icon(icon)
# lista_paczek = packageList.zainicjuj_liste_paczek(a_pix, b_pix)
lista_paczek = listOfPackages()
#lista_paczek = listOfPackages()
lista_paczek = []
lista_paczek_na_regalach = []
def narysuj_regaly():
global lista_regalow
@ -69,6 +71,7 @@ def odswiez_ekran(wozek):
screen.blit(miejsce,(a_pix, b_pix))
narysuj_siatke()
narysuj_paczki(wozek)
narysuj_paczke_na_regale()
narysuj_regaly()
wozek.draw()
pygame.display.flip()
@ -91,6 +94,13 @@ def sprawdz_ktora_kolumna(y):
def narysuj_paczki(wozek):
if wozek.ln == 0:
for paczka in lista_paczek.list:
#if wozek.ln == 0:
#for paczka in lista_paczek.list:
#if len(lista_paczek_na_regalach) == 0:
for paczka in lista_paczek:
paczka.narysuj(paczka.x, paczka.y, screen)
def narysuj_paczke_na_regale():
for paczka in lista_paczek_na_regalach:
if paczka.is_in_move is False:
paczka.narysuj(paczka.x, paczka.y, screen)

32
main.py
View File

@ -8,17 +8,19 @@ from grid import GridCellType, SearchGrid
from sklearn.tree import DecisionTreeClassifier
import pandas as pd
from plansza import x1, y1, x2, y2, x3, y3, x4, y4, a_pix, b_pix
from plansza import a_pix, b_pix
pygame.init()
def main():
wozek = Wozek()
#paczka = Paczka('duzy', 12, 'narzedzia', False, True, False, any, any, any, any, any)
paczka = Paczka('maly', 1, 'ogród', False, True, False, any, any, any, any, any)
ekran.lista_paczek.add(paczka)
paczka.update_position(a_pix, b_pix)
p1 = Paczka('duzy', 12, 'narzedzia', False, True, False, any, any, any, any, any)
p2 = Paczka('maly', 1, 'ogród', False, True, False, any, any, any, any, any)
ekran.lista_paczek.append(p1)
ekran.lista_paczek.append(p2)
p1.update_position(a_pix, b_pix)
p2.update_position(a_pix, b_pix)
grid_points = SearchGrid()
@ -42,11 +44,16 @@ def main():
if grid_points.grid[(wiersz, kolumna)] is GridCellType.PLACE: #picks up package
if wozek.ln == 0:
wozek.load_package()
wozek.dynamic_wozek_picture
paczka_pop = ekran.lista_paczek.pop()
ekran.lista_paczek_na_regalach.append(paczka_pop)
paczka_pop.is_in_move = True
wozek.storage.append(paczka_pop)
wozek.ln = wozek.ln + 1
wozek.dynamic_wozek_picture()
print(ekran.lista_paczek)
## wozek jedzie odlozyc paczke na regal
paczka1 = wozek.storage[0]
paczka1 = wozek.storage[-1]
array, reg = paczka1.tablica_do_drzewa(paczka1.kategoria)
@ -82,12 +89,15 @@ def main():
sciezka = wyszukiwanie.znajdz_sciezke(wezel)
wozek.przemiesc_wozek_po_sciezce(sciezka)
# print(wozek.storage)
if wozek.ln != 0: # drops package
wozek.drop_package()
print(paczka1)
paczka1.update_position(reg.numerWiersza*70, reg.numerKolumny*70)
paczka_pop.is_in_move = False
wozek.storage.pop()
wozek.ln = wozek.ln - 1
reg.put_package_on_the_regal(paczka1, predictions)
wozek.dynamic_wozek_picture()
ekran.odswiez_ekran(wozek)
if event.type == pygame.MOUSEBUTTONDOWN:
# lewy przycisk myszy

View File

@ -34,6 +34,7 @@ class Paczka(pygame.sprite.Sprite):
self.x = 430
self.y = 400
self.label = Etykieta(nadawca, adres, imie, nazwisko, telefon, priorytet)
self.is_in_move = False
# zmienia rozmiar obrazka w zaleznosci od rozmiaru
def __dobierz_rozmiar_obrazka(self):

View File

@ -63,11 +63,18 @@ class Wozek(pygame.sprite.Sprite):
def load_package(self):
for package in listOfPackages.list:
#for package in listOfPackages.list:
# for package in listOfPackages:
# dist = math.sqrt((self.obecnyStan.x - package.x)**2 + (self.obecnyStan.y - package.y)**2)
# if dist <= 50:
# self.add_element(package)
# # listOfPackages.list.pop()
# listOfPackages.pop()
package = listOfPackages.pop()
dist = math.sqrt((self.obecnyStan.x - package.x)**2 + (self.obecnyStan.y - package.y)**2)
if dist <= 50:
self.add_element(package)
listOfPackages.list.pop()
# listOfPackages.list.pop()
def load_packages_collision(self):
pass
@ -82,7 +89,8 @@ class Wozek(pygame.sprite.Sprite):
if package is not None:
package.x = self.obecnyStan.x
package.y = self.obecnyStan.y
listOfPackages.list.append(package)
# listOfPackages.list.append(package)
listOfPackages.append(package)
def __zainicjuj_stan_poczatkowy(self):
from wyszukiwanie import Stan