Merge pull request 'poprawione generowanie planszy' (#20) from fix_generowanie_planszy1 into master

Reviewed-on: #20
This commit is contained in:
Zuzanna Wójcik 2023-05-30 21:04:28 +02:00
commit 40ad5222a1
4 changed files with 29 additions and 19 deletions

View File

@ -7,7 +7,7 @@ EKRAN_SZEROKOSC = 770
EKRAN_WYSOKOSC = 770
screen = pygame.display.set_mode((EKRAN_SZEROKOSC, EKRAN_WYSOKOSC))
miejsce = pygame.image.load('images/miejsce_paczek.png')
miejsce = pygame.transform.scale(miejsce, (140, 140))
miejsce = pygame.transform.scale(miejsce, (70, 70))
pygame.display.set_caption("Inteligentny wozek")
icon = pygame.image.load('images/icon.png')
pygame.display.set_icon(icon)

View File

@ -29,7 +29,7 @@ class SearchGrid:
for c, d in [(x1, y1), (x1, y1+1), (x1+1, y1), (x1+1, y1+1), (x2, y2), (x2+1, y2), (x2, y2+1), (x2+1, y2+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
for e, f in [(a,b), (a+1,b), (a,b+1), (a+1,b+1)]:
for e, f in [(a,b)]:
self.grid[(e,f)] = GridCellType.PLACE

View File

@ -17,30 +17,40 @@ x1, y1, x2, y2, x3, y3, x4, y4 = [None] * 8
while True:
#wspolrzedne regalow
x1 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
y1 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
x2 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
y2 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
x3 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
y3 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
x4 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
y4 = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
x1 = random.randint(1, 3)
x2 = random.randint(1, 3)
x3 = random.randint(6, 8)
x4 = random.randint(6, 8)
y1 = random.randint(1, 3)
y2 = random.randint(6, 8)
y3 = random.randint(1, 3)
y4 = random.randint(6, 8)
#wspolrzedne miejsca paczek
a = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
b = random.randint(1, EKRAN_SZEROKOSC // blockSize - 2)
a = 5
b = 5
coords = [(x1, y1), (x1+1, y1), (x1, y1+1), (x1+1, y1+1),
#dodane wspolrzedne (0, 0), (4, 4), (4, 6), (6, 4), (6, 6) zeby regaly sie nie stykaly
table = [(0, 0), (4, 4), (4, 6), (6, 4), (6, 6),
(x1, y1), (x1+1, y1), (x1, y1+1), (x1+1, y1+1),
(x2, y2), (x2+1, y2), (x2, y2+1), (x2+1, y2+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),
(a, b), (a+1, b), (a, b+1), (a+1, b+1)]
(x4, y4), (x4+1, y4), (x4, y4+1), (x4+1, y4+1)]
#sprawdzenie czy jakies wspolrzedne sie pokrywaja
if len(coords) == len(set(coords)):
if len(table) == len(set(table)):
break
x1, x2, x3, x4, y1, y2, y3, y4, a, b = map(int, [x1, x2, x3, x4, y1, y2, y3, y4, a, b])
coordinates = [(x1, y1), (x2, y2), (x3, y3), (x4, y4)]
#przemieszanie koordynatów w parach
random.shuffle(coordinates)
#przypisanie przemieszanych wartości do zmiennych
(x1, y1), (x2, y2), (x3, y3), (x4, y4) = coordinates
x1, x2, x3, x4, y1, y2, y3, y4 = map(int, [x1, x2, x3, x4, y1, y2, y3, y4])
a_pix = obliczPixeleNaPodstawieKratek(a)
b_pix = obliczPixeleNaPodstawieKratek(b)
b_pix = obliczPixeleNaPodstawieKratek(b)

View File

@ -94,7 +94,7 @@ class Wozek(pygame.sprite.Sprite):
def __zainicjuj_stan_poczatkowy(self):
from wyszukiwanie import Stan
self.obecnyStan = Stan(70, 70, 1)
self.obecnyStan = Stan(0, 0, 1)
def przemiesc_wozek_po_sciezce(self, sciezka):
kierunek_poprzedni = self.obecnyStan.kierunek