def main():
    size = np.random.randint(20, 60)
    (posx, posy, posz) = (1.5, np.random.uniform(1, (size - 1)), 0.5)
    (rot, rot_v) = ((np.pi / 4), 0)
    (lx, ly, lz) = ((size * 20), (size * 30), 1000)
    (mr, mg, mb, maph, mapr, exitx, exity, mapt, maps) = maze_generator(int(posx), int(posy), size)
    (enx, eny, seenx, seeny, lock) = (np.random.uniform(2, (size - 3)), np.random.uniform(2, (size - 3)), 0, 0, 0)
    maph[int(enx)][int(eny)] = 0
    (shoot, sx, sy, sdir) = (1, (- 1), (- 1), rot)
    (res, res_o) = (5, [96, 112, 160, 192, 224, 260, 300, 340, 400, 480, 540, 600, 800])
    (width, height, mod, inc, rr, gg, bb) = adjust_resol(24)
    running = True
    pg.init()
    font = pg.font.SysFont('Arial', 18)
    font2 = pg.font.SysFont('Impact', 48)
    screen = pg.display.set_mode((800, 600))
    (rr, gg, bb) = (np.linspace(0, 0.8, (width * height)), np.linspace(0.5, 0.1, (width * height)), np.linspace(1, 0.1, (width * height)))
    pixels = np.dstack((rr, gg, bb))
    pixels = np.reshape(pixels, (height, width, 3))
    surf = pg.surfarray.make_surface(np.rot90((pixels * 255)).astype('uint8'))
    surf = pg.transform.scale(surf, (750, 550))
    screen.blit(surf, (25, 25))
    screen.blit(font2.render(" FinFET's PyTracing Maze  ", 1, pg.Color('red')), (45, 95))
    screen.blit(font2.render(" FinFET's PyTracing Maze  ", 1, pg.Color('blue')), (55, 105))
    screen.blit(font2.render(" FinFET's PyTracing Maze ", 1, pg.Color('white')), (50, 100))
    screen.blit(font2.render(' Loading, please wait... ', 1, pg.Color('black'), pg.Color('grey')), (50, 300))
    pg.display.update()
    clock = pg.time.Clock()
    pg.mouse.set_visible(False)
    et = 0.1
    mplayer = np.zeros([size, size])
    (enx, eny, mplayer, et, shoot, sx, sy, sdir, seenx, seeny, lock) = agents(enx, eny, maph, posx, posy, rot, et, shoot, sx, sy, sdir, mplayer, seenx, seeny, lock)
    (sstart, timer, count, autores, smooth) = (None, 0, (- 100), 1, 0)
    pause = 0
    pg.mixer.set_num_channels(3)
    ambient = pg.mixer.Sound('soundfx/HauntSilentPartner.mp3')
    ambient.set_volume(0.5)
    runfx = pg.mixer.Sound('soundfx/run.mp3')
    shotfx = pg.mixer.Sound('soundfx/slap.mp3')
    killfx = pg.mixer.Sound('soundfx/shutdown.mp3')
    respawnfx = pg.mixer.Sound('soundfx/respawn.mp3')
    successfx = pg.mixer.Sound('soundfx/success.mp3')
    failfx = pg.mixer.Sound('soundfx/fail.mp3')
    pg.mixer.Channel(0).play(ambient, (- 1))
    pg.mixer.Channel(1).play(respawnfx)
    run = 1
    score = 0
    ticks = (pg.time.get_ticks() / 100000)
    while running:
        count += 1
        for event in pg.event.get():
            if ((event.type == pg.QUIT) or ((event.type == pg.KEYDOWN) and (event.key == pg.K_ESCAPE))):
                if (not pause):
                    pause = 1
                    pg.mixer.Channel(1).play(respawnfx)
                    endmsg = (' Game paused. Current score: ' + str(score))
                else:
                    endmsg = (' Thanks for playing! Total score: ' + str(score))
                    pg.mixer.Channel(1).play(killfx)
                    running = False
            if ((sstart == None) and ((event.type == pg.MOUSEBUTTONDOWN) or (event.type == pg.MOUSEBUTTONUP))):
                shoot = 1
            if (event.type == pg.KEYDOWN):
                if (event.key == ord('p')):
                    if (not pause):
                        pause = 1
                        endmsg = (' Game paused. Current score: ' + str(score))
                    elif ((int(posx) != exitx) or (int(posy) != exity)):
                        pause = 0
                if (pause and (event.key == ord('n'))):
                    pause = 0
                    size = np.random.randint(20, 60)
                    (posx, posy, posz) = (1.5, np.random.uniform(1, (size - 1)), 0.5)
                    (rot, rot_v) = ((np.pi / 4), 0)
                    (mr, mg, mb, maph, mapr, exitx, exity, mapt, maps) = maze_generator(int(posx), int(posy), size)
                    (enx, eny, seenx, seeny, lock, run) = (0, 0, 0, 0, 0, 1)
                    (shoot, sx, sy, sstart) = (0, (- 1), (- 1), None)
                    mplayer = np.zeros([size, size])
                    et = 0.1
                    (enx, eny, mplayer, et, shoot, sx, sy, sdir, seenx, seeny, lock) = agents(enx, eny, maph, posx, posy, rot, et, shoot, sx, sy, sdir, mplayer, seenx, seeny, lock)
                    count = (- 100)
                    if autores:
                        (width, height, mod, inc, rr, gg, bb) = adjust_resol(24)
                    pg.mixer.Channel(1).play(respawnfx)
                if (event.key == ord('t')):
                    autores = (not autores)
                if (event.key == ord('y')):
                    smooth = (not smooth)
                if (not autores):
                    if (event.key == ord('q')):
                        if (res > 0):
                            res = (res - 1)
                            (width, height, mod, inc, rr, gg, bb) = adjust_resol(res_o[res])
                    if (event.key == ord('e')):
                        if (res < (len(res_o) - 1)):
                            res = (res + 1)
                            (width, height, mod, inc, rr, gg, bb) = adjust_resol(res_o[res])
        if (not pause):
            (rr, gg, bb) = super_fast(width, height, mod, inc, posx, posy, posz, rot, rot_v, mr, mg, mb, lx, ly, lz, mplayer, exitx, exity, mapr, mapt, maps, rr, gg, bb, enx, eny, sx, sy, size)
            pixels = np.dstack((rr, gg, bb))
            pixels = np.reshape(pixels, (height, width, 3))
            surf = pg.surfarray.make_surface(np.rot90((pixels * 255)).astype('uint8'))
            if (shoot or smooth):
                surf = pg.transform.smoothscale(surf, (800, 600))
            else:
                surf = pg.transform.scale(surf, (800, 600))
            screen.blit(surf, (0, 0))
            fpss = int((1000 / (pg.time.get_ticks() - (ticks * 100000))))
            fps = font.render(((((str(fpss) + ' w: ') + str(width)) + '  Score: ') + str(score)), 1, pg.Color('coral'))
            screen.blit(fps, (10, 0))
            if (autores and (count > 10)):
                if ((fpss < 50) and (width > 100)):
                    count = 0
                    (width, height, mod, inc, rr, gg, bb) = adjust_resol(int((width * 0.8)))
                if ((fpss > 65) and (width < 728)):
                    count = 0
                    (width, height, mod, inc, rr, gg, bb) = adjust_resol(int((width * 1.1)))
            if ((int(posx) == exitx) and (int(posy) == exity)):
                endmsg = ' You escaped safely! '
                pg.mixer.Channel(1).play(successfx)
                score += 1
                pause = 1
            pressed_keys = pg.key.get_pressed()
            et = (clock.tick() / 500)
            if (et > 0.5):
                et = 0.5
            if (shoot or (sstart != None)):
                if (sstart == None):
                    pg.mixer.Channel(2).play(shotfx)
                    if ((fpss < 60) and autores):
                        count = (- 50)
                        (width, height, mod, inc, rr, gg, bb) = adjust_resol(int((width * 0.8)))
                    sstart = pg.time.get_ticks()
                elif ((pg.time.get_ticks() - sstart) > 500):
                    (shoot, sx, sy, sstart) = (0, (- 1), (- 1), None)
            if (enx == 0):
                if (not run):
                    pg.mixer.Channel(1).play(killfx)
                    run = 1
                if (np.random.uniform() > 0.999):
                    (cos, sin) = (np.cos(rot), np.sin(rot))
                    for ee in range(100):
                        enx = np.clip(np.random.normal(posx, 5), 1, (size - 2))
                        eny = np.clip(np.random.normal(posy, 5), 1, (size - 2))
                        dtp = (((enx - posx) ** 2) + ((eny - posy) ** 2))
                        if ((maph[int(enx)][int(eny)] == 0) and (dtp > 16) and (dtp < 49)):
                            break
                    if (maph[int(enx)][int(eny)] != 0):
                        (enx, eny) = (0, 0)
                    else:
                        (seenx, seeny, lock) = (enx, eny, 0)
                        screen.blit(font2.render(' Enemy Respawning! ', 1, pg.Color('red'), pg.Color('grey')), (300, 50))
                        pg.mixer.Channel(1).play(respawnfx)
            else:
                dtp = (((enx - posx) ** 2) + ((eny - posy) ** 2))
                if (dtp < 1):
                    score -= 1
                    endmsg = (' You died! Current score: ' + str(score))
                    pg.mixer.Channel(1).play(failfx)
                    (enx, eny, seenx, seeny, lock) = (0, 0, 0, 0, 0)
                    pause = 1
                    surf = pg.surfarray.make_surface(np.rot90((255 - (pixels * 255))).astype('uint8'))
                    surf = pg.transform.smoothscale(surf, (800, 600))
                    screen.blit(surf, (0, 0))
                elif (dtp > 300):
                    (enx, eny, seenx, seeny, lock) = (0, 0, 0, 0, 0)
                    run = 0
            ticks = (pg.time.get_ticks() / 100000)
            lx = ((size / 2) + (1000 * np.cos(ticks)))
            ly = ((size / 2) + (1000 * np.sin(ticks)))
            (posx, posy, rot, rot_v, shoot) = movement(pressed_keys, posx, posy, rot, rot_v, maph, et, shoot, sstart)
            pg.mouse.set_pos([400, 300])
            mplayer = np.zeros([size, size])
            (enx, eny, mplayer, et, shoot, sx, sy, sdir, seenx, seeny, lock) = agents(enx, eny, maph, posx, posy, rot, et, shoot, sx, sy, sdir, mplayer, seenx, seeny, lock)
            if (run and ((seenx == posx) or (seeny == posy))):
                run = False
                pg.mixer.Channel(1).play(runfx)
        else:
            clock.tick(30)
            screen.blit(font2.render(" FinFET's PyTracing Maze  ", 1, pg.Color('red')), (45, 45))
            screen.blit(font2.render(" FinFET's PyTracing Maze  ", 1, pg.Color('blue')), (55, 55))
            screen.blit(font2.render(" FinFET's PyTracing Maze ", 1, pg.Color('white')), (50, 50))
            screen.blit(font2.render(endmsg, 1, pg.Color('salmon'), (100, 34, 60)), (50, 320))
            if ((int(posx) == exitx) and (int(posy) == exity)):
                screen.blit(font2.render((' Your current score is ' + str(score)), 1, pg.Color('grey'), (80, 34, 80)), (50, 390))
            else:
                screen.blit(font2.render(' Press P to continue ', 1, pg.Color('grey'), (80, 34, 80)), (50, 390))
            screen.blit(font2.render(' Press N for a new game ', 1, pg.Color('grey'), (45, 34, 100)), (50, 460))
            screen.blit(font2.render(' Press ESC to leave ', 1, pg.Color('grey'), (13, 34, 139)), (50, 530))
        pg.display.update()
    screen.blit(font2.render(endmsg, 1, pg.Color('salmon'), (100, 34, 60)), (50, 320))
    pg.mixer.fadeout(1000)
    pg.display.update()
    print(endmsg)
    pg.time.wait(2000)
    pg.quit()
def main():
    size = np.random.randint(20, 60)
    (posx, posy, posz) = (1.5, np.random.uniform(1, (size - 1)), 0.5)
    (rot, rot_v) = ((np.pi / 4), 0)
    (lx, ly, lz) = ((size * 20), (size * 30), 1000)
    (mr, mg, mb, maph, mapr, exitx, exity, mapt, maps) = maze_generator(int(posx), int(posy), size)
    (enx, eny, seenx, seeny, lock) = (np.random.uniform(2, (size - 3)), np.random.uniform(2, (size - 3)), 0, 0, 0)
    maph[int(enx)][int(eny)] = 0
    (shoot, sx, sy, sdir) = (1, (- 1), (- 1), rot)
    (res, res_o) = (5, [96, 112, 160, 192, 224, 260, 300, 340, 400, 480, 540, 600, 800])
    (width, height, mod, inc, rr, gg, bb) = adjust_resol(24)
    running = True
    pg.init()
    font = pg.font.SysFont('Arial', 18)
    font2 = pg.font.SysFont('Impact', 48)
    screen = pg.display.set_mode((800, 600))
    (rr, gg, bb) = (np.linspace(0, 0.8, (width * height)), np.linspace(0.5, 0.1, (width * height)), np.linspace(1, 0.1, (width * height)))
    pixels = np.dstack((rr, gg, bb))
    pixels = np.reshape(pixels, (height, width, 3))
    surf = pg.surfarray.make_surface(np.rot90((pixels * 255)).astype('uint8'))
    surf = pg.transform.scale(surf, (750, 550))
    screen.blit(surf, (25, 25))
    screen.blit(font2.render(" FinFET's PyTracing Maze  ", 1, pg.Color('red')), (45, 95))
    screen.blit(font2.render(" FinFET's PyTracing Maze  ", 1, pg.Color('blue')), (55, 105))
    screen.blit(font2.render(" FinFET's PyTracing Maze ", 1, pg.Color('white')), (50, 100))
    screen.blit(font2.render(' Loading, please wait... ', 1, pg.Color('black'), pg.Color('grey')), (50, 300))
    pg.display.update()
    clock = pg.time.Clock()
    pg.mouse.set_visible(False)
    et = 0.1
    mplayer = np.zeros([size, size])
    (enx, eny, mplayer, et, shoot, sx, sy, sdir, seenx, seeny, lock) = agents(enx, eny, maph, posx, posy, rot, et, shoot, sx, sy, sdir, mplayer, seenx, seeny, lock)
    (sstart, timer, count, autores, smooth) = (None, 0, (- 100), 1, 0)
    pause = 0
    pg.mixer.set_num_channels(3)
    ambient = pg.mixer.Sound('soundfx/HauntSilentPartner.mp3')
    ambient.set_volume(0.5)
    runfx = pg.mixer.Sound('soundfx/run.mp3')
    shotfx = pg.mixer.Sound('soundfx/slap.mp3')
    killfx = pg.mixer.Sound('soundfx/shutdown.mp3')
    respawnfx = pg.mixer.Sound('soundfx/respawn.mp3')
    successfx = pg.mixer.Sound('soundfx/success.mp3')
    failfx = pg.mixer.Sound('soundfx/fail.mp3')
    pg.mixer.Channel(0).play(ambient, (- 1))
    pg.mixer.Channel(1).play(respawnfx)
    run = 1
    score = 0
    ticks = (pg.time.get_ticks() / 100000)
    while running:
        count += 1
        for event in pg.event.get():
            if ((event.type == pg.QUIT) or ((event.type == pg.KEYDOWN) and (event.key == pg.K_ESCAPE))):
                if (not pause):
                    pause = 1
                    pg.mixer.Channel(1).play(respawnfx)
                    endmsg = (' Game paused. Current score: ' + str(score))
                else:
                    endmsg = (' Thanks for playing! Total score: ' + str(score))
                    pg.mixer.Channel(1).play(killfx)
                    running = False
            if ((sstart == None) and ((event.type == pg.MOUSEBUTTONDOWN) or (event.type == pg.MOUSEBUTTONUP))):
                shoot = 1
            if (event.type == pg.KEYDOWN):
                if (event.key == ord('p')):
                    if (not pause):
                        pause = 1
                        endmsg = (' Game paused. Current score: ' + str(score))
                    elif ((int(posx) != exitx) or (int(posy) != exity)):
                        pause = 0
                if (pause and (event.key == ord('n'))):
                    pause = 0
                    size = np.random.randint(20, 60)
                    (posx, posy, posz) = (1.5, np.random.uniform(1, (size - 1)), 0.5)
                    (rot, rot_v) = ((np.pi / 4), 0)
                    (mr, mg, mb, maph, mapr, exitx, exity, mapt, maps) = maze_generator(int(posx), int(posy), size)
                    (enx, eny, seenx, seeny, lock, run) = (0, 0, 0, 0, 0, 1)
                    (shoot, sx, sy, sstart) = (0, (- 1), (- 1), None)
                    mplayer = np.zeros([size, size])
                    et = 0.1
                    (enx, eny, mplayer, et, shoot, sx, sy, sdir, seenx, seeny, lock) = agents(enx, eny, maph, posx, posy, rot, et, shoot, sx, sy, sdir, mplayer, seenx, seeny, lock)
                    count = (- 100)
                    if autores:
                        (width, height, mod, inc, rr, gg, bb) = adjust_resol(24)
                    pg.mixer.Channel(1).play(respawnfx)
                if (event.key == ord('t')):
                    autores = (not autores)
                if (event.key == ord('y')):
                    smooth = (not smooth)
                if (not autores):
                    if (event.key == ord('q')):
                        if (res > 0):
                            res = (res - 1)
                            (width, height, mod, inc, rr, gg, bb) = adjust_resol(res_o[res])
                    if (event.key == ord('e')):
                        if (res < (len(res_o) - 1)):
                            res = (res + 1)
                            (width, height, mod, inc, rr, gg, bb) = adjust_resol(res_o[res])
        if (not pause):
            (rr, gg, bb) = super_fast(width, height, mod, inc, posx, posy, posz, rot, rot_v, mr, mg, mb, lx, ly, lz, mplayer, exitx, exity, mapr, mapt, maps, rr, gg, bb, enx, eny, sx, sy, size)
            pixels = np.dstack((rr, gg, bb))
            pixels = np.reshape(pixels, (height, width, 3))
            surf = pg.surfarray.make_surface(np.rot90((pixels * 255)).astype('uint8'))
            if (shoot or smooth):
                surf = pg.transform.smoothscale(surf, (800, 600))
            else:
                surf = pg.transform.scale(surf, (800, 600))
            screen.blit(surf, (0, 0))
            fpss = int((1000 / (pg.time.get_ticks() - (ticks * 100000))))
            fps = font.render(((((str(fpss) + ' w: ') + str(width)) + '  Score: ') + str(score)), 1, pg.Color('coral'))
            screen.blit(fps, (10, 0))
            if (autores and (count > 10)):
                if ((fpss < 50) and (width > 100)):
                    count = 0
                    (width, height, mod, inc, rr, gg, bb) = adjust_resol(int((width * 0.8)))
                if ((fpss > 65) and (width < 728)):
                    count = 0
                    (width, height, mod, inc, rr, gg, bb) = adjust_resol(int((width * 1.1)))
            if ((int(posx) == exitx) and (int(posy) == exity)):
                endmsg = ' You escaped safely! '
                pg.mixer.Channel(1).play(successfx)
                score += 1
                pause = 1
            pressed_keys = pg.key.get_pressed()
            et = (clock.tick() / 500)
            if (et > 0.5):
                et = 0.5
            if (shoot or (sstart != None)):
                if (sstart == None):
                    pg.mixer.Channel(2).play(shotfx)
                    if ((fpss < 60) and autores):
                        count = (- 50)
                        (width, height, mod, inc, rr, gg, bb) = adjust_resol(int((width * 0.8)))
                    sstart = pg.time.get_ticks()
                elif ((pg.time.get_ticks() - sstart) > 500):
                    (shoot, sx, sy, sstart) = (0, (- 1), (- 1), None)
            if (enx == 0):
                if (not run):
                    pg.mixer.Channel(1).play(killfx)
                    run = 1
                if (np.random.uniform() > 0.999):
                    (cos, sin) = (np.cos(rot), np.sin(rot))
                    for ee in range(100):
                        enx = np.clip(np.random.normal(posx, 5), 1, (size - 2))
                        eny = np.clip(np.random.normal(posy, 5), 1, (size - 2))
                        dtp = (((enx - posx) ** 2) + ((eny - posy) ** 2))
                        if ((maph[int(enx)][int(eny)] == 0) and (dtp > 16) and (dtp < 49)):
                            break
                    if (maph[int(enx)][int(eny)] != 0):
                        (enx, eny) = (0, 0)
                    else:
                        (seenx, seeny, lock) = (enx, eny, 0)
                        screen.blit(font2.render(' Enemy Respawning! ', 1, pg.Color('red'), pg.Color('grey')), (300, 50))
                        pg.mixer.Channel(1).play(respawnfx)
            else:
                dtp = (((enx - posx) ** 2) + ((eny - posy) ** 2))
                if (dtp < 1):
                    score -= 1
                    endmsg = (' You died! Current score: ' + str(score))
                    pg.mixer.Channel(1).play(failfx)
                    (enx, eny, seenx, seeny, lock) = (0, 0, 0, 0, 0)
                    pause = 1
                    surf = pg.surfarray.make_surface(np.rot90((255 - (pixels * 255))).astype('uint8'))
                    surf = pg.transform.smoothscale(surf, (800, 600))
                    screen.blit(surf, (0, 0))
                elif (dtp > 300):
                    (enx, eny, seenx, seeny, lock) = (0, 0, 0, 0, 0)
                    run = 0
            ticks = (pg.time.get_ticks() / 100000)
            lx = ((size / 2) + (1000 * np.cos(ticks)))
            ly = ((size / 2) + (1000 * np.sin(ticks)))
            (posx, posy, rot, rot_v, shoot) = movement(pressed_keys, posx, posy, rot, rot_v, maph, et, shoot, sstart)
            pg.mouse.set_pos([400, 300])
            mplayer = np.zeros([size, size])
            (enx, eny, mplayer, et, shoot, sx, sy, sdir, seenx, seeny, lock) = agents(enx, eny, maph, posx, posy, rot, et, shoot, sx, sy, sdir, mplayer, seenx, seeny, lock)
            if (run and ((seenx == posx) or (seeny == posy))):
                run = False
                pg.mixer.Channel(1).play(runfx)
        else:
            clock.tick(30)
            screen.blit(font2.render(" FinFET's PyTracing Maze  ", 1, pg.Color('red')), (45, 45))
            screen.blit(font2.render(" FinFET's PyTracing Maze  ", 1, pg.Color('blue')), (55, 55))
            screen.blit(font2.render(" FinFET's PyTracing Maze ", 1, pg.Color('white')), (50, 50))
            screen.blit(font2.render(endmsg, 1, pg.Color('salmon'), (100, 34, 60)), (50, 320))
            if ((int(posx) == exitx) and (int(posy) == exity)):
                screen.blit(font2.render((' Your current score is ' + str(score)), 1, pg.Color('grey'), (80, 34, 80)), (50, 390))
            else:
                screen.blit(font2.render(' Press P to continue ', 1, pg.Color('grey'), (80, 34, 80)), (50, 390))
            screen.blit(font2.render(' Press N for a new game ', 1, pg.Color('grey'), (45, 34, 100)), (50, 460))
            screen.blit(font2.render(' Press ESC to leave ', 1, pg.Color('grey'), (13, 34, 139)), (50, 530))
        pg.display.update()
    screen.blit(font2.render(endmsg, 1, pg.Color('salmon'), (100, 34, 60)), (50, 320))
    pg.mixer.fadeout(1000)
    pg.display.update()
    print(endmsg)
    pg.time.wait(2000)
    pg.quit()