diff --git a/src/machine.rs b/src/machine.rs index 65041456..34c19073 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -392,32 +392,34 @@ pub fn quick_term_or_rec( let mut reset = 1; for cycle in 1..sim_lim { - if reset == 0 { - ref_state = state; - ref_tape = tape.clone(); - let head = ref_tape.head; - leftmost = head; - rightmost = head; - reset = cycle; - } - - reset -= 1; - let Some(&(color, shift, next_state)) = comp.get(&(state, tape.scan())) else { return drop_halt; }; - let same = state == next_state; + let curr_state = state; + + state = next_state; + + let same = curr_state == next_state; if same && tape.at_edge(shift) { return true; } - tape.step(shift, color, same); + if reset == 0 { + ref_state = curr_state; + ref_tape = tape.clone(); + let head = ref_tape.head; + leftmost = head; + rightmost = head; + reset = cycle; + } - state = next_state; + reset -= 1; + + tape.step(shift, color, same); let curr = tape.head;