Code Monkey home page Code Monkey logo

python-simple-turing-machine's Introduction

Python Simple Turing Machine

A Python Simple Turing Machine (STM) execution simulator

image

Install

$ git clone https://github.com/DrankRock/Python-Simple-Turing-Machine.git
$ cd Python-Simple-Turing-Machine
$ python3 SimpleTuring.py -h

Usage

Arguments

-h, --help

usage: SimpleTuring.py [-h] [-b BAND] [-c COLORS [COLORS ...]] [-di] [-ds DISPLAY_SLEEP] [-es END_SYMBOLS [END_SYMBOLS ...]] [-i INT [INT ...]] [-m MACHINE] [-nb N_BANDS] [-nu N_UPLET] [-p PRINT]
                       [-ph] [-si START_INDEX] [-t TRANSITIONS [TRANSITIONS ...]]

options:
  -h, --help            show this help message and exit
  -b BAND, --band BAND  Starting band for the program
  -c COLORS [COLORS ...], --colors COLORS [COLORS ...]
                        Specify a color for a character ( -c B red ). l to list colors
  -di, --display-inline
                        Display the current line inline
  -ds DISPLAY_SLEEP, --display-sleep DISPLAY_SLEEP
                        sleep n milliseconds between each step
  -es END_SYMBOLS [END_SYMBOLS ...], --end-symbols END_SYMBOLS [END_SYMBOLS ...]
                        Specify the symbols to count after ending. Format : -es Y S
  -i INT [INT ...], --int INT [INT ...]
                        integers to add to the band
  -m MACHINE, --machine MACHINE
                        Use a custom machine previously added to the source code above, line 27 and below
  -nb N_BANDS, --n-bands N_BANDS
                        Specify the number of bands (default : 1, min : 1)
  -nu N_UPLET, --n-uplet N_UPLET
                        Specify the accepted n-uplet (default : 4, min : 4)
  -p PRINT, --print PRINT
                        Print a python version of the machine, to add it in the code, line 27 and below
  -ph, --print-human    Print the current machine as a human readable format
  -si START_INDEX, --start-index START_INDEX
                        Starting index of the machine
  -t TRANSITIONS [TRANSITIONS ...], --transitions TRANSITIONS [TRANSITIONS ...]
                        Transitions (format : '<start state> <read> <action> <end state>' Example : "0 B | 1" "0 | | 0"


-b, --band "custom band"

Specify a custom band.
python SimpleTuring.py -m cleaner -b "BBB|||||This is a custom band"
Screenshot from 2023-02-10 07-13-09

-c, --colors <character> <color>

Specify a custom color/effect/background for any character
python SimpleTuring.py -c l
image python SimpleTuring.py -m cleaner -b "BBB|||||This is a custom band" -c \| yellow B red
image

-di, --display-inline

Print every step on top of each other instead of the one after the other.
python SimpleTuring.py -m cleaner -i 1 2 -di
image

-ds, --display-sleep <time in ms>

Set a delay in milliseconds between each step. Especially useful with --display-inline, to see the steps happen.
python SimpleTuring.py -m cleaner -i 4 3 -di -ds 500
display-sleep

-es, --end-symbols <symbol1> .. <symbol n>

Set the symbols to count at the end of the execution
python SimpleTuring.py -m cleaner -b "BBB|||Y||BB" -es Y \|
image

-i, --int <int1> <int2> .. <int n>

Set the band as a list of integers with the format n = |^(n+1)B
python SimpleTuring.py -i 2 4 -m cleaner
image

-m, --machine <machine name>

Specify a saved machine to be executed. This machine needs to be saved to the code under the line 30. After creating your machine with the -t arguments, you can print as a python list with -p and add it to the code. More of this is explained under the -p, --print tab. python SimpleTuring.py -i 2 -m cleaner

-p, --print <machine name>

Print the current machine as a list in python, to be copied in the dedicated space in the SimpleTuring.py code, as shown below. This makes it possible to use it by name with -m, --machine option.

After executing with -p cleaner SimpleTuring.py
image image

-nb, --n-bands <int>

Not implemented yet, but aims to make it possible to use multiple bands

TODO

  - gdb mode with s, j <n steps>, c, b <state>, p 
- n-bands /!\ Most important
- save machines to .machines file with -s
    --> load 
    --> append multiple machines
    --> load machines from custom file 
- Complete http://morphett.info/turing/turing.html support
    maybe -m <morphet file>
- Accept transitions from file
    -t <filename>
- accept * as "do not move"
- .config to save parameters, maybe run -d to run default specified in config

Contact

If you encounter any kind of problem, or to have a chat, you can contact me on Discord @MattV#7337

python-simple-turing-machine's People

Contributors

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