added variable pointer start position
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user