Giter Club home page Giter Club logo

turing-machine-tape-generator's Introduction

Turing Machine Tape Generator

This repository contains Python scripts designed to automate the generation and compilation of LaTeX/TikZ source code for visually representing the tape of a Turing machine.

Examples

The resulting diagram follows the same style as that in Charles Petzold's book The Annotated Turing. It consists of a grid of squares containing characters from a given input string, with an ultra-thick border around a specified square to indicate the current position of the head, a customizable total number of squares and a few style options.

Structure

The program consists of three scripts:

  1. generate_tikz_code.py – Generates the LaTeX/TikZ source code and saves it to the file tikz_code.tex.
  2. compile_latex.py – Compiles the generated LaTeX file to a PDF and saves it inside an output folder together with associated .aux and .log files.
  3. main.py – Main script; calls the other two scripts to produce the LaTeX source code and PDF files.

Requirements

  • Python 3.x
  • A LaTeX distribution with pdflatex (e.g., TeX Live, MiKTeX)
  • The TikZ package for LaTeX

Usage

Using any text editor, modify the values of the variables in main.py to customize the tape's content according to the explanations there. Here's the code used to produce the first example in the preceding figure:

s = "r e c u r s i o n !"  # The string to be printed on the tape
head = 15    # The position of the head (0-based)
length = 20  # The total number of squares
style = "c"  # Additional style options

Then run the main script through the Python interpreter:

python3 main.py

turing-machine-tape-generator's People

Contributors

pzuehlke avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

joshuabloemer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.