示例#1
0
    def initImage(self):
        """
        Loads the image from the file, using the appropriate function.
        """
        if LAB_PATH is None:
            print("Generating labyrinth...")
            self.labyrinth = maze(*MAZE_SIZE, size=SIZE)
            self.im = lab_to_im(self.labyrinth)
        else:
            print("Reading labyrinth from {}...".format(LAB_PATH))
            if LAB_PATH.endswith("map"):
                load_fun = load_from_map_file
            else:
                load_fun = load_from_img
            self.labyrinth, self.im = load_fun(LAB_PATH)

        self.pix = self.im.load()
        print("Read!")
        self.b1.configure(state="normal")
示例#2
0
                    for j in range(1, ns + 1):
                        nx = size * x1 + j
                        if nx < w:
                            lab[nx, size * y1 + i] = True
                        else:
                            break

    lab[0, 0] = 1
    lab.start = 0, 0
    lab[lab.w - 2, lab.h - 2] = 1
    lab.goal = lab.w - 2, lab.h - 2

    return lab


def empty_maze(w, h):
    lab = Labyrinth(w, h)
    lab[0, 0] = 1
    lab.start = 0, 0
    lab[w - 2, h - 2] = 1
    lab.goal = w - 2, h - 2
    return lab


if __name__ == "__main__":
    w, h = 3, 5

    e = maze(w, h)
    im = lab_to_im(e)
    # im.show()