r/madeinpython • • May 05 '20

Conway's Game Of Life in 13 lines of code using kernel convolutions

30 Upvotes

8 comments sorted by

4

u/69shaolin69 May 05 '20

Not hating or anything but Is it 13 lines? I see a line extending far beyond pep8 standard. Like 10x times long.

3

u/slipped_and_missed_x May 05 '20

Haha yeah. Not gonna lie, obeying PEP8 standards wasn't really my goal with this one :)

2

u/69shaolin69 May 05 '20

Fair. Nice job ?

well the title sounds amazing for sure.

Good job.

4

u/awesomeprogramer May 05 '20

So you're just using convolution to count the neighbors? Then that really long line is applying the rules as a long Boolean expression? Anything else?

2

u/slipped_and_missed_x May 05 '20

No that's basically it. I'm not really trying to anything particularly valuable here I just think it's neat

2

u/awesomeprogramer May 05 '20

It is really neat! I wonder what a cuda enabled pytorch version would look like. Definitely overkill, bit could be fun.

5

u/tur2rr2rrr May 05 '20

Nice one. Shame he passed recently.

0

u/[deleted] May 05 '20

[deleted]

1

u/slipped_and_missed_x May 05 '20

OpenCV. It's just displaying a 2d numpy array of booleans