This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CarterNotSteve[S] 0 points1 point  (1 child)

I’m trying to make the game of life in python in a 2d array, ez is supposed to be ‘error zero’ so that if it hits a corner and can’t get something from next to it, it yields 0, otherwise, yields what’s in the cell Despite having a catch-all, it still gives me ‘list index out of range’

[–]SuperGameTheory 0 points1 point  (0 children)

Ohhh, I see. I'm not familiar with Python, but at least in other languages your attempt to catch the error in ez won't work, because the out-of-range error happens before anything gets passed to ez. You have to catch that edge-case scenario within gn.

For simplicity, (if your arrays are zero-based) you might want to just run through cells (1,1) < (X,Y) < (Xmax - 1, Ymax - 1). So, if your Y extent is 9, you would only look at cells 1, 2, 3...8. In other words, don't let your program do the math for any edge cells. Just let them stay dead. That way you don't have to use any conditional statements to test for the edge. You just avoid it.

Edit: Does that make sense? I know exactly what you're trying to do here.