Need help for fragile maze

I cant seem to find the error in my code. It says that right is not a function

# Escape from the maze!
# Some doors are blocked, some open when you are near them.
intersection = []
dbr = 16
startRoom = {"x": 18, "y": 19}
def right():
    if hero.isPathClear(hero.pos, {"x" : hero.pos.x + dbr,"y" : hero.pos.y}):
        return 1
    return 0
def up() :
    if hero.isPathClear(hero.pos, {"x" : hero.pos.x,"y" : hero.pos.y + dbr}):
        return 1
    return 0
def down() :
    if hero.isPathClear(hero.pos, {"x" : hero.pos.x,"y" : hero.pos.y - dbr}):
        return 1
    return 0
def left() :
    if hero.isPathClear(hero.pos, {"x" : hero.pos.x - dbr,"y" : hero.pos.y}):
        return 1
    return 0
while True:
    right = right()
    up = up()
    left = left()
    down = down()
    if (right + up + left + down) >= 2 :
        #si j'ai un choix je dois noter l'intersection
        intersection.append(hero.pos)
        if up == 1:
            hero.moveXY(hero.pos.x, hero.pos.y + dbr)
        elif right == 1:
            hero.moveXY(hero.pos.x+dbr, hero.pos.y)
        elif left == 1:
            hero.moveXY(hero.pos.x-dbr, hero.pos.y)
        elif down == 1:
            hero.moveXY(hero.pos.x, hero.pos.y-dbr)
    if (right + up + left + down) == 0:
        for i in range(len(intersection)) :
            if hero.isPathClear(hero.pos, intersection[i]):
                hero.moveXY(intersection[i].x, intersection[i].y)
    elif right  == 1:
        hero.moveXY(hero.pos.x+dbr, hero.pos.y)
    elif up == 1 :
        hero.moveXY(hero.pos.x, hero.pos.y+dbr)
    elif down == 1 :
        hero.moveXY(hero.pos.x, hero.pos.y-dbr)
    elif left == 1 :
        hero.moveXY(hero.pos.x-dbr, hero.pos.y)

Welcome to the forum @Ynnos ! :partying_face: This is a friendly place where you can ask help on levels, report bugs, or just chat with other coders! Don’t forget to read the guidelines if you haven’t yet. Have a great time!

After the first call of right = right() right() is no more a function but simple integer.
So this substitution will get rid of the error but will not solve the level:

while True:
    dir_right = right()
    dir_up = up()
    dir_left = left()
    dir_down = down()
    if (dir_right + dir_up + dir_left + dir_down) >= 2 :
        intersection.append(hero.pos)
        if dir_up == 1:
            hero.moveXY(hero.pos.x, hero.pos.y + dbr)
        elif dir_right == 1:
            hero.moveXY(hero.pos.x+dbr, hero.pos.y)
        elif dir_dir_left == 1:
            hero.moveXY(hero.pos.x-dbr, hero.pos.y)
        elif dir_down == 1:
            hero.moveXY(hero.pos.x, hero.pos.y-dbr)
    if (dir_right + dir_up + dir_left + dir_down) == 0:
        for i in range(len(intersection)) :
            if hero.isPathClear(hero.pos, intersection[i]):
                hero.moveXY(intersection[i].x, intersection[i].y)
    elif dir_right  == 1:
        hero.moveXY(hero.pos.x+dbr, hero.pos.y)
    elif dir_up == 1 :
        hero.moveXY(hero.pos.x, hero.pos.y+dbr)
    elif dir_down == 1 :
        hero.moveXY(hero.pos.x, hero.pos.y-dbr)
    elif dir_left == 1 :
        hero.moveXY(hero.pos.x-dbr, hero.pos.y)

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.