dodany wybór osoby

This commit is contained in:
Adam Osiowy 2020-05-12 00:02:05 +02:00
parent bb100e9f8d
commit e06cbf4acd
48 changed files with 33 additions and 30 deletions

53
game.py
View File

@ -7,6 +7,18 @@ import shutil
import astar
import uczenie_kacper as kacper
smieci_path = ''
# PODAJ OSOBE PRZED URUCHOMIENIEM (kacper/adamB/adamO)
osoba = 'kacper'
if osoba == 'kacper':
smieci_path = 'resources/smieci'
elif osoba == 'adamB':
smieci_path = 'resources/smieci_stare'
else:
smieci_path = 'resources/smieci_stare'
pygame.init()
# kolory
@ -32,11 +44,6 @@ ILOSC_KOLUMN = 15
WINDOW_SIZE = [1300, 980]
# TEST DODAWANIA SMIECI Z POJEDYNCZEGO DOMU DO FOLDERU KONTENERA ZE SZKLEM
# for d in lista_domow:
# for s in d.smieci:
# kontener_szklo.dodajSmiec(s)
def game():
obiekty = utworzObiekty()
nieodwiedzone_domy = obiekty["wspolrzedne_domow"]
@ -52,9 +59,9 @@ def game():
while not done:
# obsluga zdarzen typu nacisniecie klawisza lub przycisku myszy
for event in pygame.event.get(): # User did something
if event.type == pygame.QUIT: # If user clicked close
done = True # Flag that we are done so we exit this loop
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
elif event.type == pygame.MOUSEBUTTONDOWN:
# Zapisywanie pozycji myszki po kliknieciu
pozycja_myszki = pygame.mouse.get_pos()
@ -77,7 +84,8 @@ def game():
rysowaniePlanszy(obiekty)
while nieodwiedzone_domy:
nieodwiedzone_domy.sort(key=lambda x: astar.heurystyka((obiekty["smieciarka"].x, obiekty["smieciarka"].y), x))
nieodwiedzone_domy.sort(
key=lambda x: astar.heurystyka((obiekty["smieciarka"].x, obiekty["smieciarka"].y), x))
cel = nieodwiedzone_domy.pop(0)
obiekty["smieciarka"].astar_move(obiekty, (obiekty["smieciarka"].x, obiekty["smieciarka"].y), cel)
pozX = cel[0]
@ -86,7 +94,15 @@ def game():
if dom.x == pozX and dom.y == pozY:
while dom.smieci:
smiec = dom.smieci.pop(0)
rodzaj = ""
if osoba == 'kacper':
rodzaj = kacper.przewidz(smiec)
elif osoba == 'adamB':
pass
else:
pass
if rodzaj == "paper":
obiekty["smieciarka"].dodajPapier(smiec)
elif rodzaj == "glass":
@ -97,7 +113,8 @@ def game():
obiekty["smieciarka"].dodajPlastik(smiec)
while nieodwiedzone_kontenery:
nieodwiedzone_kontenery.sort(key=lambda x: astar.heurystyka((obiekty["smieciarka"].x, obiekty["smieciarka"].y), x))
nieodwiedzone_kontenery.sort(
key=lambda x: astar.heurystyka((obiekty["smieciarka"].x, obiekty["smieciarka"].y), x))
cel = nieodwiedzone_kontenery.pop(0)
obiekty["smieciarka"].astar_move(obiekty, (obiekty["smieciarka"].x, obiekty["smieciarka"].y), cel)
pozX = cel[0]
@ -194,12 +211,6 @@ def utworzObiekty():
plansza[0, 4].setJestKontenerem(True)
plansza[0, 4].setObiekt(kontener_metal)
# kontener_organiczne = modele.Kontener(2, 2, "pozostale")
# kontener_organiczne.setImage(pygame.image.load(
# "resources/plansza/pojemnik_organiczne.png"))
# plansza[2, 2].setJestKontenerem(True)
# plansza[2, 2].setObiekt(kontener_organiczne)
kontener_papier = modele.Kontener(4, 0, "papier")
kontener_papier.setImage(pygame.image.load(
"resources/plansza/pojemnik_papier.png"))
@ -220,7 +231,7 @@ def utworzObiekty():
domy_lista = pygame.sprite.Group()
smieci_lista = [os.path.join(path, filename)
for path, dirs, files in os.walk("resources/smieci")
for path, dirs, files in os.walk(smieci_path)
for filename in files]
# informacje o ilosci smieci w domach
@ -238,18 +249,10 @@ def utworzObiekty():
all_sprites_list.add(dom)
lista_domow = domy_lista.sprites()
acc = 0
for d in lista_domow:
for j in range(5):
smiec = random.choice(smieci_lista)
d.dodajSmiec(smiec)
# print('')
# print(smiec)
# print(kacper.przewidz(smiec))
# if kacper.przewidz(smiec) in smiec:
# acc += 1
# smieci_lista.remove(smiec)
# print(acc)
# ustawienie wysypiska, rozmiar wysypiska 5x5
for i in range(5):

View File

@ -58,7 +58,7 @@ class Smieciarka(pygame.sprite.Sprite):
def astar_move(self, obiekty, start, cel):
sciezka = astar.astar(obiekty, start, (cel[0], cel[1]))
print(sciezka)
# print(sciezka)
if sciezka:
for koord in sciezka:
if koord[0] == self.x - 1 and koord[1] == self.y:

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

0
uczenie_adamO.py Normal file
View File