-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTuringModules.py
More file actions
33 lines (26 loc) · 1.05 KB
/
TuringModules.py
File metadata and controls
33 lines (26 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sys
from pathlib import Path
# Add the 'python_machine' directory to sys.path
base_dir = Path(__file__).resolve().parent
turing_path = base_dir / "python_machine"
sys.path.insert(0, str(turing_path))
# Import Turing Machine components
from python_machine.TuringMachine import TuringMachine, MachineLogic, TuringConfig
from python_machine.TuringGUI import TuringGUI
# Re-export if used as a module
__all__ = ["TuringMachine", "MachineLogic", "TuringConfig", "TuringGUI"]
if __name__ == "__main__":
init_rules = """
INIT | FIND | R
FIND | FIND | R
FIND _ HALT | R
""".strip()
init_tape = "|||"
# Run headless machine (console-only)
_, basic_results, basic_resources = TuringMachine(init_rules).run_machine(
init_tape, play_type=0, visualize=True
)
print("\n".join(basic_results + [""] + basic_resources))
# Run GUI simulator
_, gui_results, gui_resources = TuringGUI(init_rules).run_simulator(init_tape)
print("\n".join(gui_results + [""] + gui_resources))