Skip to content

pchchv/tm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Turing Machine implement in Golang

What is this Turing Machine

A Turing machine is an abstract "machine" that manipulates symbols on a strip of tape according to a table of rules; to be more exact, it is a mathematical model that defines such a device. Despite the model's simplicity, given any computer algorithm, a Turing machine can be constructed that is capable of simulating that algorithm's logic. (Wiki Quote)

Install

go get github.com/pchchv/tm

Usage

package main

import (
    "fmt"
    . "github.com/pchchv/tm"
)

func main() {
    nTM := NewTM()
    //Input State and declare if it is final state
    nTM.InputState("0", false)
    nTM.InputState("1", true)
    //Input config
    // InputConfig parameter as follow:
    // - SourceState, 
    // - Input
    // - Modified Value
    // - DestinationState
    // - Tape Head Move Direction
    nTM.InputConfig("0", "1", "1", "1", MoveRight)
    nTM.InputConfig("0", "0", "1", "0", MoveLeft)
    nTM.InputConfig("1", "0", "1", "0", MoveLeft)
    nTM.InputConfig("1", "1", "1", "1", MoveRight)
    //Input tape data
    nTM.InputTape("0", "0", "1", "1", "0", "0", "0")
    //Run TM to the finish (if exist)
    nTM.Run()
    fmt.Println("New Tape:=", nTM.ExportTape())
}

About

Simple Turing Machine implement in Golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages