Conway's Game of Life: boundaries (12)

2 Name: #!/usr/bin/anonymous : 2008-01-29 22:42 ID:UJfHP0Q5

Quick solution off the top of my head (and not having actually read the code) would be when accessing an array element, instead just writing [x], write [(x+size)%size]. The %size will take care of positive wraparound, and adding size would wrap from the lower boundary. (Relatedly, I'm guessing you're going from [1] to [size-1] to deal with edge cases -- with this modulus arithmetic you wouldn't have to do that.)

This thread has been closed. You cannot post in this thread any longer.