Comments (2)
Hey!
In Conway's game we take each cell one by one and count up the number of activated neighbours to apply given rule. E.g. if cell is active and has less then 2 active neighbours, it is deactivated (it dies). That's an algorithm you would easily write using 3 embedded for-loops.
What you can do, instead, is to define a 2D kernel function in form
K=
[1 1 1]
[1 10 1]
[1 1 1]
The game board is another 2D function that looks like
B=
[1 0 0 0 ...]
[0 1 1 0 ...]
[0 0 0 0 ...]
[...]
Now, the convolution between two functions (board function and kernel) is defined via Fourier transform as ift(fft(B) * fft(K)
. And thats exactly what I do. This efectively computes the exact same think as if you would write 3 embedded for-loops, count current cells for 10 and its neighbours for 1 and sum up the values for each cell.
You certainly can use scipy.signal
package to convolve the functions and ignore FT completely.
So, I think you can understand the code without knowing FT, however, since the convolution is defined in terms of FT, understanding definitely helps. On the other side, I have seen convolution to be defined and used in many areas without bothering about its relationship to FT.
FT, convolution, kernels, etc. is used in such a broad area that it's difficult to recommend any particular source.
from 100days.
Thank you so much for the explanation!!
from 100days.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 100days.