osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Conway's game of Life, just because.


On Tue, May 7, 2019 at 1:00 PM MRAB <python at mrabarnett.plus.com> wrote:
>
> On 2019-05-07 19:29, Eli the Bearded wrote:
> > In comp.lang.python, Paul Rubin  <no.email at nospam.invalid> wrote:
> >
> > Thanks for posting this. I'm learning python and am very familiar with
> > this "game".
> >
> >> #!/usr/bin/python3
> >> from itertools import chain
> >>
> >> def adjacents(cell):            # generate coordinates of cell
neighbors
> >>     x, y = cell                 # a cell is just an x,y coordinate pair
> >>     return ((x+i,y+j) for i in [-1,0,1] for j in [-1,0,1] if i or j)
> >
> [snip]
> >
> > Elijah
> > ------
> > is the torus game board unintentional?
> >
> I've never seen a version of Conway's Game of Life where the board
> doesn't wrap around.

I don't think I've ever seen one where it does.