Turing machine written by scratch

  Most people don't care about scratch because they think it's played by children. It is true that the way of building blocks is not suitable for professional programmers to write code, but don't underestimate scratch, in any case, it is also Turing complete. Also, procedures support recursion, although they cannot return a value.

  Although the calculation speed will be very slow, it is still possible to design a Turing machine.

  The idea is actually not that troublesome. The scatch variable is weakly typed and supports list. Although theoretically, even if scratch does not have this list, it is Turing complete, but after all, it is a lot of trouble.

  When we make a Turing machine, we use the list to put the paper tape of the Turing machine. Of course, the various rules of the Turing machine should also be placed on the list. The rules are {x||x is the state}, {x|x is the paper tape value}, {x||x is the state}, {x|x is the paper tape Value}, {left, right} on a quintuple relationship, representing the current state, current tape value, future state, future tape value, head direction. For convenience, it is divided into 5 lists to install. Of course, the status and paper tape value can be represented by integers starting from 0, and the left and right are represented by 01.

  The operation of the Turing machine is not complicated. I won't go into details here. If you forget how to run it, please refer to https://en.wikipedia.org/wiki/Turing_machine

  The following is a Turing machine:

  

  Haha, although the sparrow is small, it has all the internal organs. Although scratch is just something children play, it can theoretically implement all operations, which is amazing, isn't it?

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325138028&siteId=291194637