GithubHelp home page GithubHelp logo

porfanid / turingmachine Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 20 KB

Python script to create and test Turring machines

Home Page: https://pypi.org/project/turing-machine-utils/

License: MIT License

Python 100.00%
algorithm artificial-intelligence automata complexity computational-science computational-theory education machine-learning open-source python3

turingmachine's Introduction

TuringMachine

Table of Contents

Introduction

Run any Turing machine possible using this function and see if the turing machine, accepts or rejects the tape you input to it.

Installation

pip install turing-machine-utils

Usage

from turing_machine_utils import create_turing_machine

# Define Turing Machine states, alphabet, and transition rules
states = ['q0', 'q1', 'accept', 'discard']
transition_rules = {
    ('q0', '0'): ('q1', '1', 'R'),
    ('q0', '1'): ('q0', '0', 'R'),
    ('q1', '0'): ('accept', '0', 'L'),
    ('q1', '1'): ('discard', '1', 'L'),
}

# Define the input tape
tape = ['0', '1', '0', '1', '0']

# Run the Turing Machine
result, new_tape, state, symbol = create_turing_machine(tape, states, transition_rules)
print("Result:", result)

remember that the machine will start calculating the response from the first state. So the first element on the states list must be the beginning state

The result will be:

  1. 1 if the tape is accepted by the turing machine
  2. -1 if the state is discarded by the turing machine
  3. 0 if an undefined transition is found by the turing machine

The new_tape is the tape with the changes to the original tape

The state and symbol are normally None. They get values that say when the turing machine reached an undefined point

Configuration

No specific configuration options are available at the moment.

Contributing

Feel free to contribute by reporting issues, suggesting improvements, or submitting pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.

turingmachine's People

Contributors

porfanid avatar

Watchers

 avatar  avatar  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.