Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
/ TuringMachine Public archive

A Turing machine interpreter made in Java using Processing libraries.

License

Notifications You must be signed in to change notification settings

margual56/TuringMachine

Repository files navigation

JUnit Report

DEPRECATION WARNING ⚠️

This program is no longer maintained!

Please, use the newer version: https://github.com/margual56/turing-machine-2.0

It has lots of new cool features, a better syntaxis and it's written in rust!

TuringMachine

A Turing machine interpreter made in Java using Processing libraries.


This is the Example2.tm (which duplicates the input) running in real time

Downloads

Using the Turing Machine in the CLI

(From version 3 onwards)

Usage: java -jar TuringMachine.jar [options]
				
	A simple Turing Machine simulator with a GUI. It uses the syntax we use at class in Computability (EPI Gijón).
				
Optional arguments:
	(none)			Run the program normally (GUI mode)
	-h, --help			Show this help message and exit
	--headless FILE [-v]	Run in headless mode (print the result and exit, no GUI). Write `-v` to get the verbose output.
	-e, --example		Print an example program and exit
					
Note:
	You can only provide one argument at a time. If more than one is provided, just the first one is going to be taken into account.

Programming in Turing Machine code

Inside the examples folder, there are 5 example programs of how to code a Turing Machine program. The extension of the files has to be .tm.

Firstly, you define the initial state of the tape (example):

{q011101111};

After that (in this order), you define the final state:

#define F = {f};

And finally, you define all the states that you want. The syntax is the following: (state, oldValue, newValue, L/R/H (meaning "left/right/halt"), goToState);

Example:

(q0, 1, 0, R, q1);

Comments can be written using //

So a fully-working program would look like this (from Example1.tm, it adds the two input numbers):

// a + b

{q011111011};

#define F = {q2};

(q0, 1, 0, R, q1);

(q1, 1, 1, R, q1);
(q1, 0, 0, R, q2);

(q2, 1, 0, H, q2);
(q2, 0, 0, H, q2);

Use the interpreter

Go to the releases page and download the latest version. It is programmed in Java, so it is cross-platform.
When you execute it, it will prompt you to select the ".tm" file (the turing machine code) you want to execute. Select it and it will start running.

  • spacebar -> pause/resume (or restart if the execution has finished)
  • right arrow -> Advance just one instruction forward
  • enter -> Jump to the end of the execution
  • r -> Stop, load a new program and run it
  • ESC -> Exit cleanly
  • + -> Increase speed
  • - -> Decrease speed
  • = -> Restore initial speed

License

GNU GPLv3