Click here to Skip to main content
15,615,466 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
import curses
from curses import wrapper
import queue
import time
maze = [
    ['#','#','#','#','#','0','#','#','#'],
    ['#',' ',' ',' ',' ',' ',' ',' ','#'],
    ['#',' ','#','#',' ','#','#',' ','#'],
    ['#',' ','#',' ',' ',' ','#',' ','#'],
    ['#',' ', '#',' ','#',' ','#',' ','#'],
    ['#',' ', '#',' ','#',' ','#',' ','#'],
    ['#',' ','#',' ','#',' ','#','#','#'],
    ['#',' ',' ',' ',' ',' ',' ',' ','#'],
    ['#','#','#','#','#','#','#','X','#',]
]

def print_maize(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,value)

def main(stdscr):
    curses.init_pair(1,curses.COLOR_BLUE,curses.COLOR_BLACK)
    blue_and_black = curses.color_pair(1)
    stdscr.clear()
    print_maize(maze,stdscr)
    stdscr.refresh()
    stdscr.getch()

wrapper(main)



error code
<pre>  File "c:\Python\New python learning.py\new proj.py", line 24, in print_maize
    stdscr.addstr(i,j,value)
_curses.error: addwstr() returned ERR


What I have tried:

trying to create a maze game but not getting the output at this stage ,
error code as mentioned above



I am not able to understand how to proceed ahead
Posted
Updated 24-Nov-22 1:47am
Comments
Richard MacCutchan 24-Nov-22 7:32am    
Have you called initscr to initialise the curses module?
I see that the call to wrapper does that for you.
ALEXANDER ABRAHAM 2022 24-Nov-22 8:00am    
No how do you call that can you help? the tutorial person when he runs this code he gets the output, even this code also doesn't work COLOR_BLUE,curses.COLOR_BLACK in the code
Richard MacCutchan 24-Nov-22 8:04am    
Then as suggested by OriginalGriff below, ask the person who wrote the tutorial. The only information that we have is the code you have posted. See also the resulting output I got in my Solution below.

Go back to where you got the tutorial from, and ask there: we have no access to the code or any idea what it should look like.

THough a better solution would be to stop watching tutorials, and read a book on Python instead: they cover the subject much better than video tutorials do, especially if you found it on YouTube ...
 
Share this answer
 
I just ran that code and the result is:
#####0###
#       #
# ## ## #
# #   # #
# # # # #
# # # # #
# # # ###
#       #
#######X#

I suspect the error message is the clue, in that it appears to think that your characters are in Unicode rather than ASCII. But I have no idea why that may be. You should check the tutorial again to see if there is any mention of this.
 
Share this answer
 
v3
Comments
ALEXANDER ABRAHAM 2022 24-Nov-22 8:04am    
no such mention in the tutorial, tutorial link https://www.youtube.com/watch?v=txKBWtvV99Y&t=331s
in the first 10minutes he mentions.
hows that possible your getting the result and not me?
it is related to extension, even i have downloaded python3 -m pip install windows-curses extension also
Richard MacCutchan 24-Nov-22 8:07am    
Sorry, I only downloaded the curses library to test your code. But I have no experience of it, so cannot offer any suggestions.
ALEXANDER ABRAHAM 2022 24-Nov-22 8:08am    
ok, do you know any better sites on internet to learn free python projects with explanation
Richard MacCutchan 24-Nov-22 8:13am    
I have a better idea, go to The Python Tutorial — Python 3.10.8 documentation[^] and learn the language properly. Once you understand it you will find samples much easier to work with.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900