0

I'm trying to program Conway's game of life on Python, without using classes or the self. thing. I'm really new to curses, and I want to make a condition like:

if screen[y][x] == '*':
     neighbour_count+=1

Where y and x are the coordinates on the screen and I check to see how many neighbours a cell has. I keep getting 'object not suscriptable', and I really don't know how to make that condition work.

Weirdo
  • 42
  • 9
  • You have to keep [a copy of] the on-screen content in an off-screen 2D list. Update the list when the screen updates. Consult the list to check the screen contents. – DYZ Jun 13 '17 at 04:14

1 Answers1

1

You can do this via the inch() or instr() functions. But, you probably shouldn't. Instead, keep copies of the "board" in appropriate structures (one for the current generation, and one for the next), calculate with those, and update the screen each generation.

William McBrine
  • 2,166
  • 11
  • 7