[Tutor] More trouble debugging my game of life program
Brian van den Broek
broek at cc.umanitoba.ca
Mon Jun 4 00:09:22 CEST 2007
Matt Smith said unto the world upon 06/03/2007 04:12 PM:
> Hi,
>
> I've got my program working correctly (or so it seems) with my original
> data file (r-pentomino.txt - attached) but when I run it with a larger
> (30*30) file (big-r-pentomino - also attached) in an attempt to make it
> work with out so many edge effects it returns the following error
> message:
>
> Traceback (most recent call last):
> File "Python/game_of_life/life.py", line 75, in <module>
> curses.wrapper(main)
> File "curses/wrapper.py", line 44, in wrapper
> File "Python/game_of_life/life.py", line 60, in main
> draw_board(matrix, stdscr, generation)
> File "Python/game_of_life/life.py", line 28, in draw_board
> stdscr.addch(y + 1, x + 1, ' ')
> _curses.error: addch() returned ERR
>
> I thought I had designed the program to work with any text file as long
> as the lines are all the same length so I cannot understand why I get
> this error message. When I read through the code I cannot see a reason
> why the program should work for one size file and not another. The part
> of the program that is failing is just drawing a space character at a
> particular location on the screen.
>
> Here is the listing of the program that I have also attached:
<snip>
Hi Matt and all,
I'm not familiar with curses, and I didn't look too closely at your
code. But, if I understand you aright, things work fine with a 15x15
matrix, and go sideways with the 30x30.
The first thing I would do to try to track down the problem would be
to try 15x30 and 30x15 matrices. If you have two cases where one
behaves as expected and one does not, it is usually very useful to try
to match the two cases as closely as possible as an aid to pinpointing
the problem.
HTH,
Brian vdB
More information about the Tutor
mailing list