File:Turing-machine.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file (SVG file, nominally 385 × 83 pixels, file size: 23 KB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
English: Turing-machine

Created using the tikz package and compiled with pdflatex.

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{ifthen}
\usepackage{tikz}
\usetikzlibrary{chains}
\usetikzlibrary{calc, decorations.pathmorphing}
\tikzstyle{track}=[thick, draw, minimum height=5mm, minimum width=7mm, fill=green!35,outer sep=0pt]
\tikzstyle{head}=[very thick, draw, minimum height=6mm, minimum width=5mm, fill=none,outer sep=0pt]

\def\DrawTrack#1{
\begin{scope}[start chain=1 going right,node distance=-0.15mm]
    % start track
    \node [on chain=1,track,draw=none, track, fill=none, draw=none] at (0,-\i*0.5) (node\i0){};
    \draw [fill=green!35,thick] (node\i0.north east) -- ++(.15,0) 
    {-- ($(node\i0.north east)+(-\shiftl-\rate*\i,0)$)}
    decorate [decoration={zigzag, segment length=.10cm, amplitude=.015cm}] 
    {-- ($(node\i0.south east)+(-\shiftl-\rate*\i-\rate,0)$)} -- (node\i0.south east) -- cycle;
    % draw track
      \foreach [count=\j] \element in \adlist {     
	  \ifthenelse{\j = \head}{ % read-write heads current position
		    \node [on chain=1,track, fill=red!35] (node\i\j){\element};
	      }
	      {
		    \node [on chain=1,track] (node\i\j) {\element};
	      }
      }    
    % close track
    \draw [fill=green!35, thick] (node\i\j.north east) -- ++(.15,0) 
    {-- ($(node\i\j.north east)+(\shiftr-\rate*\i,0)$)}
    decorate [decoration={zigzag, segment length=.10cm, amplitude=.015cm}] 
    {-- ($(node\i\j.south east)+(\shiftr-\rate*\i-\rate,0)$)} -- (node\i\j.south east) -- cycle;
    \node [on chain=1,track, fill=none, draw=none] (end\i) {};
    \node [right = of end\i]{\tiny tape};
    
\end{scope}
}

\newcount\lastnode
\begin{document}
% Define the turing machine as a list of lists of symbols on each track of the tape.
\newcommand{\tracks}{{1,1,,1, 0, 1 , 0,, 1 , 1, 0, 1}}
\newcommand{\head}{9}

% parameters
\newcommand{\shiftr}{0.35} % increase for more tracks
\newcommand{\shiftl}{0.1} % increase for more tracks
\newcommand{\rate}{0.05}
\begin{tikzpicture}
% Draw program node
\draw (4.3, 1) node [draw, thick, rectangle, minimum height= 1cm, minimum width=4cm, fill=white, rounded corners] (program){program};

% Draw tracks
\foreach [count=\i] \adlist in \tracks {
    \DrawTrack{\i, \adlist}   
}
% Draw Head
\draw[very thick] {($(node1\head.north west)+(-0,0.07)$)} 
		  {-- ($(node1\head.north east)+(+0,0.07)$)}
		  {-- ($(node\i\head.south east)+(+0,-0.07)$)}
		  {-- ($(node\i\head.south west)+(-0,-0.07)$)}
		  -- cycle;
\draw[thick, rounded corners=3pt] (program) {-- node[right]{\tiny head} ($(node1\head.north)+(+0,0.07)$)};
\end{tikzpicture}
\end{document}
Date
Source Own work
Author Wdvorak

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current20:31, 2 September 2016Thumbnail for version as of 20:31, 2 September 2016385 × 83 (23 KB)Wdvorak (talk | contribs)User created page with UploadWizard

There are no pages that use this file.

Metadata