Turing Machine

github

Overview

Have you ever wondered if Python is Turing complete? Well now you don’t have to!

This project is a fun recreation of the classic Turing Machine. A Turing Machine is a hypothetical computing machine which consists of the bare minimum components required for computation and can be used to solve any computable problem. This machine has three simple components:

The project implements a virtual Turing Machine with these components and support for custom programs and inputs. Since no personal project is complete without visuals, the Turing Machine has a live ASCII animation while running.

Technical Details

Programs

The Turing Machine accepts any properly formatted program via a text file. Instruction components are space separated, and support wildcards. * matches any symbol or indicates no action, _ matches a blank cell.

Syntax

StateReadWriteMoveState
current statecell inputcell outputmovement directionnew state

Programs for Turing Machines are written as state machines following this cycle:

read cell > write cell > update state > move tape > repeat

The project is packaged with some example programs, courtesy of this wonderful implementation written for the web.

CLI

The program has various flags for toggling animation, setting animation speed, and preloading tapes / programs. If no tape or program input is provided on the commandline, the user is prompted for it via a menu.

While running the machine will display cycle counts and the current state, if an runtime error is encountered the program halts and associated information is displayed to the user.