This is a C++ program that emulates a Turing Machine. It can read a program description from a file and operate on a memory tape based on the program's instructions.
- Emulates a Turing Machine with a configurable program and memory.
- Supports custom program and memory tape files.
- Provides detailed execution information for debugging purposes (enable with
_DEBUG
).
- C++ compiler (e.g., g++ or Visual Studio)
- Git (optional, for cloning the repository)
-
Clone this repository (if you haven't already):
git clone https://github.com/Tugamer89/TuringMachineEmulator.git cd TuringMachineEmulator
-
Compile the program:
g++ -o turing-machine main.cpp
To run the Turing Machine emulator, execute the compiled program with the desired program and memory tape files:
./turing-machine program.tm memory.mem
Replace program.tm
and memory.mem
with your program and memory tape file paths.
The program file (program.tm
) contains instructions for the Turing Machine. It follows a specific format:
# Comment lines start with a hash (#) symbol and are ignored.
# Initial configuration line:
<current_status> <initial_memory_index> -
# Transition rules:
<current_status> <current_value> <new_status> <new_value> <move_direction>
<current_status>
: The current state of the Turing Machine.<initial_memory_index>
: The initial index of the memory tape.<current_value>
: The current value at the tape head.<new_status>
: The new state to transition to.<new_value>
: The new value to write to the tape.<move_direction>
: The direction to move the tape head (<
,>
, or-
for left, right, or stay, respectively).
Contributions are welcome! If you find any issues or have improvements to suggest, please open an issue or create a pull request.
This project is open-source and available under the MIT License. Feel free to use, modify, and distribute the code for your purposes. See the LICENSE file for more details about the MIT License.
- Special thanks to Alan Turing for pioneering the concept of Turing Machines and their significance in the field of computer science.