Skip to content

Instantly share code, notes, and snippets.

@ytaki0801
Created December 10, 2022 11:41
Show Gist options
  • Save ytaki0801/d662f01cbd3858e01e2b4980487566f9 to your computer and use it in GitHub Desktop.
Save ytaki0801/d662f01cbd3858e01e2b4980487566f9 to your computer and use it in GitHub Desktop.
Wolfram's 2-state 3-symbol Turing Machine
# 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