I created a functioning Turing Machine using Notepad++ and its Find/Replace regular expression engine. Take a look at busybeaver.txt
in Notepad++ or (almost) any other text editor with a regex find/replace option.
What it looks like
The machine consists of the tape, the read/write head, the current instruction, and the instruction sets.
- The tape is a line beginning with a
!
followed by a string of0
s and1
s. - The read/write head is a line beginning with a
[
followed by a preset amount of whitespace and ending with a^
. - The current instruction is a line beginning with a
#
and followed by the name of the current instruction. - The instruction sets are the remaining lines, formatted like
>C.I:WMN
C
current instruction name.I
the input from the current tape position. Either0
or1
. Each instruction has execution parameters for both inputs.W
the output to be written to the tape at the current position. Either0
or1
.M
the movement of the read/write head. A0
moves the head one position to the left. A1
moves it to the right.N
the name of the next instruction to be executed at the new tape position.
This is an example of a tape with one instruction set named INST
INST
with the current tape position containing a 1
.
INST.1
defines the following instructions: write a 0
, move the head to the right, go to instruction INST
.
After overwriting the tape with a 0
and moving the head to the right, the new tape position will contain a 0
, and we will still be in instruction INST
.
INST.0
defines the following instructions: write a 0
, move the head to the left, go to instruction HALT
.
Because the tape already contains a 0
at that point, the content of the tape does not change. After moving the head to the left, we go to instruction HALT
. Because no instruction set is defined with this name, the machine will stop running.
How to run it
To run the machine, plug the following into the find/replace box of Notepad++:
Find what:
Make sure the Regular expression
option and the Wrap around
box are selected.
Make sure the . matches newline
box is unselected.
Then keep clicking the Replace
button.
The machine halts once the regular expression no longer finds a match and the replace stops functioning.
TIP: to save yourself some clicking, you can click Replace
once and then hold Enter
on your keyboard t