added variable pointer start position

This commit is contained in:
2024-03-21 16:38:28 +01:00
parent 8753b6b68d
commit 32c32e4e3a
2 changed files with 9 additions and 0 deletions

View File

@@ -6,8 +6,12 @@ mod turing;
const LENGTH: usize = 64;
fn main() {
// create turing machine
let mut machine = TuringMachine::new();
// set pointer start position
machine.set_pointer(0);
// config turing machine belt
machine.set_belt(1, Value::Hash);
machine.set_belt(2, Value::One);

View File

@@ -57,6 +57,11 @@ impl TuringMachine {
self.belt[index] = value;
}
pub fn set_pointer(&mut self, index: usize) -> () {
// set pointer start position
self.pointer = index;
}
pub fn set_transition(&mut self, state: u64, value: Value, next_state: u64) -> () {
// If the State is not in the HashMap, add it
if self.transitions.get(&state).is_none() {