Code Monkey home page Code Monkey logo

turing-machine's Introduction

Turing Machine

This file contains the all around subject of the project and file contents

Constantinescu Vlad

  1. Subject:

Turing Machine:

- I implemented a turing machine using data structures and input commands
- The user of this code can use certain commands to manipulate the tape
- The commands with explanations are listed below:

    UPDATE COMMANDS:

    - MOVE_LEFT moves the current position to the left w/ one cell

    - MOVE_RIGHT moves the current position to the right w/ one cell
    if there is nothing to the right, inserts '#' char and moves on it

    - MOVE_LEFT_CHAR <param> moves the current position to the left at
    the specified char. If it isn't found, or the current char is the one
    searched for, it doesn't change the current position

    - MOVE_RIGHT_CHAR <param> moves the current position to the right at
    the specified char. If it isn't found, inserts '#' char and moves on it.
    If the current char is the one searched for, it doesn't change the current
    position

    - WRITE <param> writes the desired char over the current one, without
    modifying current position

    - INSERT_LEFT <param> inserts the specified char to the left of the current
    position. it it's the first cell, prints ERROR

    - INSERT_RIGHT <param> inserts the specified char to the right of the current
    position

    QUERY COMMANDS:

    - SHOW_CURRENT show the current position

    - SHOW show the whole tape

    UNDO/REDO:

    - UNDO moves the current position to the previous position

    - REDO moves the current position to the position before the UNDO command

    EXECUTE COMMANDS:

    - EXECUTE used to execute one UPDATE command at the time, therefore is not
    available before such a commands is used

-Restrictions:

    - The UPDATE commands are stored in a queue, where they are executed one by one
    by EXECUTE commands
    - The QUERY commands are executed at anytime
    - UNDO only works with MOVE_LEFT and MOVE_RIGHT, therefore it must
    be used after one of these two commands has been implemented
    - REDO can be used only after an UNDO has been used
  1. File contents:

turing_functions.h:

- macros for each command code and verifications
- structures for defining the commands, the tape,
command queues and UNDO/REDO stacks
- the header of the functions for manipulating the structures
of related data, as well as the requested orders and auxiliary functions

main.c:

- declaration of all data structures
- Init (data structure initialization)
- Run (Running the program)
- Free (release of data structures from memory)

turing_functions.c - declarations of functions:

- auxiliary functions:
    - tape operation: InitB, PushB, FreeB
    - queue operation: InitC, PushC, PopC
    - stack operation: InitS, PushS, PopS, FreeS
- Code: coding of commands in integer values using the detection of
certain characters from the command string and comparison by
the 'strcmp' function. The parameters of parameterized processing
functions are modified secondarily by the function
- Read: reading the command from the file and its coding
- Execute: a switch case for command execution, if there are
UPDATE commands, add them to the queue
- Run: reads a number of commands from the file, encodes each one
and runs the execution function for each encoded command (Execute)
- Free: frees the data structures declared in main.c
- command functions: the functions that the user can access

turing-machine's People

Contributors

costaalacuparmare avatar

Watchers

 avatar

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.