{"id":50127457,"url":"https://github.com/zefir1990/turing-machine","last_synced_at":"2026-05-23T20:34:51.039Z","repository":{"id":322084299,"uuid":"1088140563","full_name":"zefir1990/turing-machine","owner":"zefir1990","description":null,"archived":false,"fork":false,"pushed_at":"2025-11-02T12:41:38.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-21T21:20:31.187Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","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/zefir1990.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-02T11:54:20.000Z","updated_at":"2025-11-02T12:41:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/zefir1990/turing-machine","commit_stats":null,"previous_names":["demensdeum/turing-machine","zefir1990/turing-machine"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/zefir1990/turing-machine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zefir1990%2Fturing-machine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zefir1990%2Fturing-machine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zefir1990%2Fturing-machine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zefir1990%2Fturing-machine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zefir1990","download_url":"https://codeload.github.com/zefir1990/turing-machine/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zefir1990%2Fturing-machine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33412082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T18:09:33.147Z","status":"ssl_error","status_checked_at":"2026-05-23T18:09:31.380Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-05-23T20:34:50.040Z","updated_at":"2026-05-23T20:34:51.031Z","avatar_url":"https://github.com/zefir1990.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🧠 Dart Turing Machine Emulator\n\nA minimalistic **Turing Machine emulator** implemented entirely in **Dart**, featuring an extendable opcode system, infinite tape simulation, and several sample \"programs\" (tapes) that demonstrate printing, arithmetic, conditional branching, user input, and even a **self-replicating quine**.\n\n---\n\n## 🚀 Features\n\n- 🧾 **Finite State Control** — Centralized control flow handling all instructions.\n- ♾️ **Infinite Tape** — Implemented as a sparse map for unbounded memory access.\n- 🪄 **Tape Head** — Supports moving, reading, and writing across infinite cells.\n- 🧩 **Opcodes System** — Extensible instruction set (print, increment, input, copy, etc).\n- 🌀 **Non-deterministic Option** — Optional chaos mode for random opcode substitution.\n- 🧍 **Delegate Interface** — Clean separation between logic and memory management.\n- 💡 **Example Programs**:\n  - **Hello World**\n  - **Count to Sixteen**\n  - **Count Down to Zero**\n  - **Number Guessing Game**\n  - **Quine (self-replicating program)**\n\n---\n\n## 🧩 Opcodes\n\n| Opcode | Description |\n|--------|--------------|\n| `stop` | Halts the machine |\n| `print` | Prints the next symbol |\n| `increment next` | Increments the numeric value of the next symbol |\n| `decrement next` | Decrements the numeric value of the next symbol |\n| `if previous not equal` | Conditional execution block |\n| `move to index` | Moves the tape head to a specific index |\n| `copy from index to index` | Copies a value from one cell to another |\n| `input to next` | Reads user input and writes it to the next cell |\n| `generate random number from zero to next and write after` | Writes a random integer to tape |\n\n---\n\n## 🧮 Example Tapes\n\nThe `main()` function defines and runs several tapes sequentially:\n\n### 🖨️ 1. Hello World\nPrints “hello world” and stops.\n```dart\nhelloWorldTape.write(symbol: \"print\", at: 0);\nhelloWorldTape.write(symbol: \"hello world\", at: 1);\nhelloWorldTape.write(symbol: \"stop\", at: 2);\n```\n\n### 🔢 2. Count to Sixteen\nIncrements numbers from 0 to 16 and prints each value.\n\n### 🔻 3. Count Down to Zero\nDecrements numbers from 16 to 0 and prints each value.\n\n### 🎲 4. Guess the Number\nAsks user to guess a random number between 0 and 4.\n\n### 🪞 5. Quine\nA self-replicating Turing program that outputs its own tape source.\n\n---\n\n## ⚙️ Running the Emulator\n\n### 🧱 Requirements\n- Dart SDK ≥ 3.0  \n  Install from [dart.dev](https://dart.dev/get-dart)\n\n### ▶️ Run\n```bash\ndart run main.dart\n```\n\nYou’ll see several demo tapes execute in sequence, printing results to the console.\n\n---\n\n## 🧠 Architecture Overview\n\n```text\nFiniteStateControl\n ├─ handles opcodes and logic\n │\n ├── delegate → TuringMachine (implements FiniteStateControlDelegate)\n │     ├── TapeHead (controls current position)\n │     └── InfiniteTape (Map-based memory)\n```\n\n---\n\n## 🔍 Debug Options\n\nEnable various debug flags at the top of the file:\n\n```dart\nconst DEBUG_PRINT_ENABLED = true;\nconst DEBUG_MODE_ENABLED = true;\nconst DEBUG_PRINT_TAPE = true;\n```\n\n- `DEBUG_PRINT_ENABLED` → Log every symbol and opcode  \n- `DEBUG_MODE_ENABLED` → Step-by-step execution (press Enter to continue)  \n- `DEBUG_PRINT_TAPE` → Print tape contents after each operation  \n\n---\n\n## 🧪 Extending the Machine\n\nTo add a new opcode:\n\n1. Define it as a new constant:\n   ```dart\n   const OPCODE_NEW_OPERATION = \"new operation\";\n   ```\n2. Add it to the `opcodes` list.\n3. Implement its behavior in `FiniteStateControl.handle()`.\n\n---\n\n## 🧰 Example Output\n\n```\n---Next Tape---\nhello world\n\n---Next Tape---\n16\n15\n...\n0\nFinished!\n\n---Next Tape---\nGuess number (0-4):\n\u003e 2\nWrong!\nNumber: 3\n\n---Next Tape---\n????????????????\n(copying and printing itself...)\n```\n\n---\n\n## 📜 License\n\nMIT License  \nCopyright (c) 2025  \n\nFree to use, modify, and experiment.\n\n---\n\n## 🧑‍💻 Author\n\nDeveloped by **Ilia Prokhorov**  \nA playful exploration of computation theory, recursion, and chaos—implemented in Dart.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzefir1990%2Fturing-machine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzefir1990%2Fturing-machine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzefir1990%2Fturing-machine/lists"}