Friday January, 9, 2026

Today This Free Friday I am Working on a project on YouTube a Shortest path finder

maze = [
       ["#", "#", "#", "#", "#", "O", "#", "#", "#"],
       ["#", " ", " ", " ", " ", " ", " ", " ", "#"],
       ["#", " ", "#", "#", " ", "#", "#", " ", "#"],
       ["#", " ", "#", " ", " ", " ", "#", " ", "#"],
       ["#", " ", "#", " ", "#", " ", "#", " ", "#"],
       ["#", " ", "#", " ", "#", " ", "#", " ", "#"],
       ["#", " ", "#", " ", "#", " ", "#", "#", "#"],
       ["#", " ", " ", " ", " ", " ", " ", " ", "#"],
       ["#", "#", "#", "#", "#", "#", "#", "x", "#"]
]
  • This is the code for the maze that is in the Shortest path finder.
def print_maze(maze,stdscr, path=[]):
    BLUE = curses.color_pair(1)
    RED = curses.color_pair(2)

    for i, row in enumerate(maze):
        for j, value in enumerate(row):
            stdscr.addstr(i, j*2, value)
  • This part of the code is for to color the path and for the row that are in the maze.
def main(stadscr):
    curses.int_pair(1, curses.COLOR_BLUE, curses.COLOR_BLACK)
    curses.int_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
    

    stdscr.clear()
    print_maze(maze, stdscr)
    stdscr.refresh()
    stdscr.getch()

wrapper(main)
  • This part of the code is the code for to color the maze and get user and to color the screen for the maze.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top