Fuck you pythong

                Never    
from typing import List ,Tuple
import random
import pygame


class Pole:
    typ = 1 # 1 to ściana 0 to scierzka
    odwiedzona = False
    droga = False

    def rysuj(self, x, y, wys, szer, obszar):
        if self.typ==1:
            kolor = (0,0,0)
        elif self.typ== -1:
            kolor = (0, 255, 0)
        elif self.typ == 2:
            kolor = (255, 0, 0)
        else:
            kolor = (255,255,255)
            if self.odwiedzona:
                kolor = (255,102,255)
            if self.droga:
                kolor = (0,0,255)
        pygame.draw.rect(obszar, kolor, pygame.Rect(x*szer, y*wys, szer, wys))



class Labirynt:
    rozmiar_x = 10
    rozmiar_y = 10
    start = (0, 0)
    koniec = (rozmiar_x -1 , rozmiar_y-1)
    mapa = [] # mapa[x][y]

    def __init__(self, x, y):
        self.rozmiar_y = y
        self.rozmiar_x = x
        #self.start = (0, 0)
        self.koniec = (x -1 , y-1)
        for x in range(0,self.rozmiar_x):
            temp = []
            for y in range(0,self.rozmiar_y):
                temp.append(Pole())
            self.mapa.append(temp)
        self.mapa[self.start[0]][self.start[1]].typ = -1
        self.mapa[self.koniec[0]][self.koniec[1]].typ = 2



    def rysuj(self, obszar):
        for x in range(0,self.rozmiar_x):
            for y in range(0,self.rozmiar_y):
                self.mapa[x][y].rysuj(x, y, 10, 10, obszar)

    def sasiedzi(self, pozycja: Tuple):
        x = pozycja[0]
        y = pozycja[1]
        temp: List[Tuple] = []
        mapa = self.mapa

    #    print("x: ", x ,"y: ",y)

        if x > 0 and not mapa[x-1][y].odwiedzona: #lewo
            sasiedzi = self.sasiedzi_scierzki(x-1, y)
            if len(sasiedzi) < 2:
                temp.append((x-1, y))

        if x < self.rozmiar_x - 1 and not mapa[x+1][y].odwiedzona:  # prawo
            sasiedzi = self.sasiedzi_scierzki(x+1, y)
            if len(sasiedzi) < 2:
                temp.append((x+1, y))

        if y > 0 and  not mapa[x][y-1].odwiedzona: #gora
            sasiedzi = self.sasiedzi_scierzki(x, y-1)
            if len(sasiedzi) < 2:
                temp.append((x, y-1))

        if y < self.rozmiar_y - 1 and not mapa[x][y+1].odwiedzona: #lewo
            sasiedzi = self.sasiedzi_scierzki(x, y+1)
            if len(sasiedzi) < 2:
                temp.append((x, y+1))

        return temp

    def sasiedzi_scierzki(self, x, y):

        temp: List[Tuple] = []
        mapa = self.mapa

        if x > 0 and  mapa[x-1][y].typ < 1: #lewo
            temp.append((x-1, y))

        if x < self.rozmiar_x - 1 and  mapa[x +1 ][y].typ < 1:  # prawo
            temp.append((x+1, y))

        if y > 0 and mapa[x][y-1].typ < 1: #gora
            temp.append((x, y-1))

        if y < self.rozmiar_y - 1 and mapa[x][y+1].typ < 1: #lewo
            temp.append((x-1, y))
        return temp

    def generuj(self):
        pozycja: Tuple = self.start
        mapa = self.mapa
        mapa[pozycja[0]][pozycja[1]].odwiedzona = True
        stos = [pozycja]
        while len(stos):
            sasiedzi = self.sasiedzi(pozycja)
            if len(sasiedzi):
                i = random.randint(0, len(sasiedzi)-1)

                pozycja = sasiedzi[i]

                mapa[pozycja[0]][pozycja[1]].odwiedzona = True
                if mapa[pozycja[0]][pozycja[1]].typ != 2:
                    mapa[pozycja[0]][pozycja[1]].typ = 0
                stos.append(pozycja)
            else:
                pozycja = stos.pop()

    def rozwiaz_rekurencja(self,pozycja: Tuple):
        if pozycja == self.koniec: # jesli koniec
            return True
        x = pozycja[0]
        y = pozycja[1]
        mapa = self.mapa

        if mapa[x][y].typ == 1 or mapa[x][y].odwiedzona == True: # jesli sciana lub juz tu bylismy
            return False

        mapa[x][y].odwiedzona = True

        if x != 0: # jesli nie na lewej krawedzi
            if self.rozwiaz_rekurencja((x-1, y)):
                mapa[x][y].droga = True
                return True
        if x != self.rozmiar_x - 1 :# jesli nie na prawej krawedzi
            if self.rozwiaz_rekurencja((x+1, y)):
                mapa[x][y].droga = True
                return True
        if y != 0: # jesli nie na gornej krawedzi
            if self.rozwiaz_rekurencja((x, y-1)):
                mapa[x][y].droga = True
                return True
        if y != self.rozmiar_y - 1 :# jesli nie na dolnej krawedzi
            if self.rozwiaz_rekurencja((x, y+1)):
                mapa[x][y].droga = True
                return True
        return False

    def rozwiaz(self):
        print("max_x : ", len(self.mapa), "max_y : ", len(self.mapa[0]) )
        for x in range(0, self.rozmiar_x):
            for y in range(0, self.rozmiar_y):
                print("x: ", x, "y: ", y)
                self.mapa[x][y].odwiedzona = False

        return self.rozwiaz_rekurencja( self.start )

Raw Text