{"id":20144227,"url":"https://github.com/made2591/go-tm","last_synced_at":"2025-03-02T23:44:15.687Z","repository":{"id":57604963,"uuid":"162317987","full_name":"made2591/go-tm","owner":"made2591","description":"A Golang library to implement both deterministic and non deterministic Turing machines easily.","archived":false,"fork":false,"pushed_at":"2019-01-22T20:02:54.000Z","size":69,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-13T10:50:12.759Z","etag":null,"topics":["computable","computational","go","golang","interfaces","machine","patterns","theory","turing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/made2591.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-18T16:42:01.000Z","updated_at":"2023-05-06T13:01:20.000Z","dependencies_parsed_at":"2022-09-13T01:33:57.182Z","dependency_job_id":null,"html_url":"https://github.com/made2591/go-tm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/made2591%2Fgo-tm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/made2591%2Fgo-tm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/made2591%2Fgo-tm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/made2591%2Fgo-tm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/made2591","download_url":"https://codeload.github.com/made2591/go-tm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241587914,"owners_count":19986627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computable","computational","go","golang","interfaces","machine","patterns","theory","turing"],"created_at":"2024-11-13T22:09:19.262Z","updated_at":"2025-03-02T23:44:15.659Z","avatar_url":"https://github.com/made2591.png","language":"Go","readme":"# go-tm - Make a Turing Machine easily\n\n[![Build Status](https://travis-ci.org/made2591/go-tm.svg?branch=master)](https://travis-ci.org/made2591/go-tm)\n[![codebeat badge](https://codebeat.co/badges/53c8e4e9-5bed-485f-9a18-570bce089e1b)](https://codebeat.co/projects/github-com-made2591-go-tm-master)\n[![Coverage Status](https://coveralls.io/repos/github/made2591/go-tm/badge.svg?branch=master)](https://coveralls.io/github/made2591/go-tm?branch=master)\n[![License](https://img.shields.io/github/license/made2591/go-tm.svg)](https://opensource.org/licenses/MIT)\n[![GoDoc](https://godoc.org/github.com/made2591/go-tm?status.svg)](https://godoc.org/github.com/made2591/go-tm)\n\n![header](header.gif)\n\n**go-tm** is a library to implement both deterministic and non deterministic Turing machines easily. A related [blog-post](https://made2591.github.io/posts/golang-turing-machine) is here.\n\nThe Turing machine is a mathematical model of computation that defines an abstract machine which manipulates symbols on a strip of tape according to a list of rules. Formally, it is defined as an infinite tape of 0 with a pointer (identified by square bracket) to one specific zero,\n\n```sh\n... 0 0 0 0 0 [0] 0 0 0 0 0  ...\n```\n\na set of states identified by letters (or numbers),\n\n```sh\n{A, B, C}\n```\n\nand a list of transactions, like the one\n\n```sh\n(A, 0, B, 1, R);\n```\n\nwhere a single transaction like *(A, 0, B, 1, R)* has to been read as\n\n\u003e *Given a Turing machine in state A with the pointer over a 0, write 1, evolve to state B and move the pointer by one position in right direction over the tape*.\n\nThe pointer can only be moved by one position at time, left, right, or stay where it is.\n\n## Table of Contents\n\n- [go-tm - Make a Turing Machine easily](#go-tm---make-a-turing-machine-easily)\n  - [Table of Contents](#table-of-contents)\n  - [Installation](#installation)\n  - [Usage](#usage)\n  - [Support](#support)\n  - [Contributing](#contributing)\n\n## Installation\n\nJust get the library by:\n\n```sh\ngo get github.com/made2591/go-tm\n```\n\n## Usage\n\nTo create a new ```Symbol```, use the ```NewSymbol()``` factory method\n\n```sh\n// will create a new Symbol with value 0\nsym := NewSymbol(uint8(0))\n```\n\nTo create a new ```State```, use the ```NewState()``` or ```NewStateInitial()``` or ```NewStateFinal()``` factory methods\n\n```sh\n// will create a three new State, one with Identifier \"A\", one INITIAL and one FINAL\nsts := NewState(\"A\")\nins := NewStateInitial()\nfis := NewStateFinal()\n```\n\nTo create a new ```Transaction```, use the ```NewTransaction()``` factory method\n\n```sh\n// will move from INITIAL State, reading 0, writing 0, to state \"B\"\ntr0 := transaction.NewTransaction(state.NewInitialState(), symbol.NewSymbol(uint8(0)), state.NewState(\"B\"), symbol.NewSymbol(uint8(1)), \"N\")\n```\n\nTo init a new ```TuringMachine``` to play the [BB-2 Game](https://en.wikipedia.org/wiki/Busy_beaver)\n\n```sh\n// create states set\niss := set.NewSet()\nfss := set.NewSet()\ntrs := set.NewSet()\n\n// create transaction\ntr0 := transaction.NewTransaction(state.NewInitialState(), symbol.NewSymbol(uint8(0)), state.NewState(\"A\"), symbol.NewSymbol(uint8(0)), \"N\")\ntr1 := transaction.NewTransaction(state.NewState(\"A\"), symbol.NewSymbol(uint8(0)), state.NewState(\"B\"), symbol.NewSymbol(uint8(1)), \"R\")\ntr2 := transaction.NewTransaction(state.NewState(\"A\"), symbol.NewSymbol(uint8(1)), state.NewState(\"B\"), symbol.NewSymbol(uint8(1)), \"L\")\ntr3 := transaction.NewTransaction(state.NewState(\"B\"), symbol.NewSymbol(uint8(0)), state.NewState(\"A\"), symbol.NewSymbol(uint8(1)), \"L\")\ntr4 := transaction.NewTransaction(state.NewState(\"B\"), symbol.NewSymbol(uint8(1)), state.NewFinalState(), symbol.NewSymbol(uint8(1)), \"R\")\n// add transaction to set\ntrs.Add(tr0)\ntrs.Add(tr1)\ntrs.Add(tr2)\ntrs.Add(tr3)\ntrs.Add(tr4)\n\n// init the Turing Machine\ntm := turingMachine.NewTuringMachine(iss, fss, trs, state.NewState(state.INITIAL), symbol.NewSymbol(uint8(0)))\n\n// run the Turing Machine\ntm.Run()\n\n```\n\nor, from inside the ```root``` folder of the project\n\n```sh\ngo run main.go\n```\n\n## Support\n\nPlease [open an issue](https://github.com/made2591/go-tm/issues/new) for support.\n\n## Contributing\n\nPlease contribute using [Github Flow](https://guides.github.com/introduction/flow/). Create a branch, add commits, and [open a pull request](https://github.com/made2591/go-tm/compare/).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmade2591%2Fgo-tm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmade2591%2Fgo-tm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmade2591%2Fgo-tm/lists"}