Skip to content

Commit

Permalink
Rearrange rec check state
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdrozd committed Aug 8, 2024
1 parent da9a426 commit 9b21173
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 9b21173

Please sign in to comment.