Created
December 10, 2022 11:41
-
-
Save ytaki0801/d662f01cbd3858e01e2b4980487566f9 to your computer and use it in GitHub Desktop.
Wolfram's 2-state 3-symbol Turing Machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Wolfram's 2-state 3-symbol Turing Machine | |
from time import sleep | |
delta = {1: {0: (1, 1, 2), 1: (2, -1, 1), 2: (1, -1, 1)}, | |
2: {0: (2, -1, 1), 1: (2, 1, 2), 2: (0, 1, 1)}} | |
ds = {0: ' ', 1: '.', 2: '*'} | |
tlen = 80 | |
tape, head, state = [0] * tlen, int(tlen / 2) - 9, 1 | |
while 0 <= head < tlen: | |
t = delta[state][tape[head]] | |
tape[head], head, state = t[0], head + t[1], t[2] | |
for s in tape: print(ds[s], end='') | |
print() | |
sleep(0.005) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment