this post was submitted on 23 Aug 2023
74 points (95.1% liked)
Programming
17540 readers
85 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
The core of that Life expression works by taking the array of cells and shifting it in the eight different directions, then summing those arrays to get the population counts.
I tried translating this into Python — but I've never written
numpy
code before, so this is probably less efficient than it could be. But it does work and you can see a glider move through a few generations.The array-shifting logic is in the
populations
function, withnp.roll
being the equivalent of the APL rotate operation (written as⌽
and⊖
in the original).