cleaned up code, removed unneccessary methods in wozek
This commit is contained in:
parent
1a2c00c6e2
commit
f27ff12d88
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -110,4 +110,4 @@ def print_board(osobnik):
|
|||||||
|
|
||||||
# uruchomienie algorytmu genetycznego
|
# uruchomienie algorytmu genetycznego
|
||||||
# najlepszy_osobnik = ewolucja()
|
# najlepszy_osobnik = ewolucja()
|
||||||
# print_board(najlepszy_osobnik)
|
# print_board(najlepszy_osobnik)
|
@ -46,4 +46,4 @@ def stworz_plik_drzewa_w_pdf(clf, feature_names, class_names):
|
|||||||
graph = graphviz.Source(dot_data)
|
graph = graphviz.Source(dot_data)
|
||||||
|
|
||||||
# Wyświetlanie drzewa
|
# Wyświetlanie drzewa
|
||||||
graph.view()
|
graph.view()
|
11
grid.py
11
grid.py
@ -9,16 +9,9 @@ class GridCellType(Enum):
|
|||||||
RACK = 1
|
RACK = 1
|
||||||
PLACE = 2
|
PLACE = 2
|
||||||
|
|
||||||
# class RackCellType(Enum):
|
|
||||||
# OGROD = 0
|
|
||||||
# NARZEDZIA = 1
|
|
||||||
# KUCHNIA = 2
|
|
||||||
# MOTORYZACJA = 3
|
|
||||||
|
|
||||||
|
|
||||||
class SearchGrid:
|
class SearchGrid:
|
||||||
grid: Dict[Tuple[int, int], GridCellType] = {}
|
grid: Dict[Tuple[int, int], GridCellType] = {}
|
||||||
# rack_grid : Dict[Tuple[int, int], GridCellType] = {}
|
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self._init_grid()
|
self._init_grid()
|
||||||
@ -31,6 +24,4 @@ class SearchGrid:
|
|||||||
(x3, y3), (x3+1, y3), (x3, y3+1), (x3+1, y3+1), (x4, y4), (x4+1, y4), (x4, y4+1), (x4+1, y4+1),]:
|
(x3, y3), (x3+1, y3), (x3, y3+1), (x3+1, y3+1), (x4, y4), (x4+1, y4), (x4, y4+1), (x4+1, y4+1),]:
|
||||||
self.grid[(c,d)] = GridCellType.RACK
|
self.grid[(c,d)] = GridCellType.RACK
|
||||||
for e, f in [(plansza.a, plansza.b),(plansza.c, plansza.d)]:
|
for e, f in [(plansza.a, plansza.b),(plansza.c, plansza.d)]:
|
||||||
self.grid[(e,f)] = GridCellType.PLACE
|
self.grid[(e,f)] = GridCellType.PLACE
|
||||||
|
|
||||||
|
|
15
itemList.py
15
itemList.py
@ -1,7 +1,5 @@
|
|||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
# from paczka import Paczka
|
|
||||||
|
|
||||||
class listOfItems:
|
class listOfItems:
|
||||||
list = []
|
list = []
|
||||||
item_group = pygame.sprite.Group()
|
item_group = pygame.sprite.Group()
|
||||||
@ -12,15 +10,4 @@ class listOfItems:
|
|||||||
|
|
||||||
def remove(self):
|
def remove(self):
|
||||||
last_item = self.list.pop()
|
last_item = self.list.pop()
|
||||||
self.item_group.remove(last_item)
|
self.item_group.remove(last_item)
|
||||||
|
|
||||||
|
|
||||||
# def zainicjuj_liste_paczek(init_x, init_y):
|
|
||||||
# packageList = listOfPackages()
|
|
||||||
# demo_paczka = Paczka('duzy', 10, any, False, True, False, any, any, any, any, any)
|
|
||||||
# demo_paczka.update_position(init_x, init_y)
|
|
||||||
# packageList.add(demo_paczka)
|
|
||||||
# return packageList
|
|
||||||
|
|
||||||
|
|
||||||
|
|
18
main.py
18
main.py
@ -104,24 +104,6 @@ def main():
|
|||||||
sciezka = wyszukiwanie.znajdz_sciezke(wezel)
|
sciezka = wyszukiwanie.znajdz_sciezke(wezel)
|
||||||
wozek.przemiesc_wozek_po_sciezce(sciezka)
|
wozek.przemiesc_wozek_po_sciezce(sciezka)
|
||||||
|
|
||||||
# if grid_points.grid[(wiersz, kolumna)] is GridCellType.PLACE: #picks up package
|
|
||||||
# if wozek.ln == 0:
|
|
||||||
# wozek.load_package()
|
|
||||||
# wozek.dynamic_wozek_picture
|
|
||||||
# else:
|
|
||||||
# if wozek.ln != 0: # drops package
|
|
||||||
# wozek.drop_package()
|
|
||||||
# wozek.dynamic_wozek_picture()
|
|
||||||
|
|
||||||
# if event.type == pygame.KEYDOWN:
|
|
||||||
# if event.key == pygame.K_SPACE:
|
|
||||||
# if wozek.ln == 0:
|
|
||||||
# wozek.load_package()
|
|
||||||
# wozek.dynamic_wozek_picture()
|
|
||||||
# else:
|
|
||||||
# wozek.drop_package()
|
|
||||||
# wozek.dynamic_wozek_picture()
|
|
||||||
|
|
||||||
ekran.odswiez_ekran(wozek)
|
ekran.odswiez_ekran(wozek)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import random
|
|
||||||
import algorytm_genetyczny as genetic
|
import algorytm_genetyczny as genetic
|
||||||
|
|
||||||
def obliczPixeleNaPodstawieKratek(wymiar): #Przeliczanie współrzędnych podanych w kratkach na pixele
|
def obliczPixeleNaPodstawieKratek(wymiar): #Przeliczanie współrzędnych podanych w kratkach na pixele
|
||||||
|
13
regal.py
13
regal.py
@ -4,7 +4,6 @@ MAX_STORAGE = 3
|
|||||||
|
|
||||||
def obliczPixeleNaPodstawieKratek(wymiar): #Przeliczanie współrzędnych podanych w kratkach na pixele
|
def obliczPixeleNaPodstawieKratek(wymiar): #Przeliczanie współrzędnych podanych w kratkach na pixele
|
||||||
i = 1
|
i = 1
|
||||||
# pixele = 100
|
|
||||||
pixele = 73
|
pixele = 73
|
||||||
while (i < wymiar):
|
while (i < wymiar):
|
||||||
pixele = pixele + 70
|
pixele = pixele + 70
|
||||||
@ -33,13 +32,6 @@ class Regal(pygame.sprite.Sprite):
|
|||||||
self.kolumna = obliczPixeleNaPodstawieKratek(numerKolumny)
|
self.kolumna = obliczPixeleNaPodstawieKratek(numerKolumny)
|
||||||
self.dlugosc = obliczPixeleDlugosciRegalu(self)
|
self.dlugosc = obliczPixeleDlugosciRegalu(self)
|
||||||
|
|
||||||
package_storage = []
|
|
||||||
shelfs = { # here packages are stored
|
|
||||||
"dolna": package_storage,
|
|
||||||
"gorna": package_storage
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
storage_dolna = []
|
storage_dolna = []
|
||||||
storage_gorna = []
|
storage_gorna = []
|
||||||
|
|
||||||
@ -89,7 +81,4 @@ class Regal(pygame.sprite.Sprite):
|
|||||||
if(where == 0):
|
if(where == 0):
|
||||||
self.dolna.append(package)
|
self.dolna.append(package)
|
||||||
else:
|
else:
|
||||||
self.gorna.append(package)
|
self.gorna.append(package)
|
||||||
|
|
||||||
|
|
||||||
|
|
61
wozek.py
61
wozek.py
@ -1,6 +1,5 @@
|
|||||||
import ekran
|
import ekran
|
||||||
import pygame,math
|
import pygame
|
||||||
# from packageList import listOfPackages
|
|
||||||
from ekran import lista_itemow
|
from ekran import lista_itemow
|
||||||
from letter import Letter
|
from letter import Letter
|
||||||
import plansza
|
import plansza
|
||||||
@ -13,40 +12,19 @@ class Wozek(pygame.sprite.Sprite):
|
|||||||
self.obecnyStan = None
|
self.obecnyStan = None
|
||||||
self.height = 64
|
self.height = 64
|
||||||
self.width = 64
|
self.width = 64
|
||||||
self.image = pygame.image.load("images/pusty_wozek.png")
|
|
||||||
self.rect = self.image.get_rect()
|
|
||||||
# Credit: Forklift icons created by Smashicons - Flaticon
|
# Credit: Forklift icons created by Smashicons - Flaticon
|
||||||
# https://www.flaticon.com/free-icons/forklift
|
# https://www.flaticon.com/free-icons/forklift
|
||||||
|
self.image = pygame.image.load("images/pusty_wozek.png")
|
||||||
|
self.rect = self.image.get_rect()
|
||||||
self.__zainicjuj_stan_poczatkowy()
|
self.__zainicjuj_stan_poczatkowy()
|
||||||
|
|
||||||
def draw(self):
|
def draw(self):
|
||||||
ekran.screen.blit(self.image, (self.obecnyStan.x, self.obecnyStan.y))
|
ekran.screen.blit(self.image, (self.obecnyStan.x, self.obecnyStan.y))
|
||||||
# self.update_position(self.obecnyStan.x, self.obecnyStan.y)
|
|
||||||
|
|
||||||
#storage = ["none"] * 10
|
|
||||||
storage = []
|
storage = []
|
||||||
max_size = 10
|
max_size = 10
|
||||||
ln = len(storage)
|
ln = len(storage)
|
||||||
|
|
||||||
def add_element(self, element):
|
|
||||||
if self.ln < self.max_size:
|
|
||||||
self.storage.append(element)
|
|
||||||
self.ln=self.ln+1
|
|
||||||
else:
|
|
||||||
print("I'm full!")
|
|
||||||
def remove_element(self):
|
|
||||||
if self.ln > 0:
|
|
||||||
element = self.storage.pop()
|
|
||||||
self.ln=self.ln-1
|
|
||||||
return element
|
|
||||||
else:
|
|
||||||
print("I'm empty!")
|
|
||||||
|
|
||||||
def update_position(self, x, y):
|
|
||||||
self.obecnyStan.x = x
|
|
||||||
self.obecnyStan.y = y
|
|
||||||
self.rect.topleft = (x, y)
|
|
||||||
|
|
||||||
def dynamic_wozek_picture(self):
|
def dynamic_wozek_picture(self):
|
||||||
if self.ln == 0:
|
if self.ln == 0:
|
||||||
self.image = pygame.image.load("images/pusty_wozek.png")
|
self.image = pygame.image.load("images/pusty_wozek.png")
|
||||||
@ -57,38 +35,7 @@ class Wozek(pygame.sprite.Sprite):
|
|||||||
elif (self.ln == 10):
|
elif (self.ln == 10):
|
||||||
self.image = pygame.image.load("images/pelny_wozek_full_3_crates.png")
|
self.image = pygame.image.load("images/pelny_wozek_full_3_crates.png")
|
||||||
|
|
||||||
self.rect = self.image.get_rect()
|
self.rect = self.image.get_rect()
|
||||||
|
|
||||||
|
|
||||||
def load_package(self):
|
|
||||||
#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()
|
|
||||||
|
|
||||||
def load_packages_collision(self):
|
|
||||||
pass
|
|
||||||
# packages_collision = pygame.sprite.spritecollide(self, listOfPackages.package_group, False)
|
|
||||||
# if packages_collision:
|
|
||||||
# for package in packages_collision:
|
|
||||||
# self.add_element(package)
|
|
||||||
# listOfPackages.list.remove(package) # collision doesn't work, collision always happens
|
|
||||||
|
|
||||||
def drop_package(self):
|
|
||||||
package = self.remove_element()
|
|
||||||
if package is not None:
|
|
||||||
package.x = self.obecnyStan.x
|
|
||||||
package.y = self.obecnyStan.y
|
|
||||||
# listOfPackages.list.append(package)
|
|
||||||
listOfPackages.append(package)
|
|
||||||
|
|
||||||
def __zainicjuj_stan_poczatkowy(self):
|
def __zainicjuj_stan_poczatkowy(self):
|
||||||
from wyszukiwanie import Stan
|
from wyszukiwanie import Stan
|
||||||
|
Loading…
Reference in New Issue
Block a user