Coder Social home page Coder Social logo

Comments (2)

coells avatar coells commented on August 24, 2024 1

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.

qiansen1386 avatar qiansen1386 commented on August 24, 2024

Thank you so much for the explanation!!

from 100days.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.