Skip to content

Commit

Permalink
Check scans before slicing
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdrozd committed Nov 16, 2023
1 parent 1058c69 commit 78fe82a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tm/lin_rec.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def copy(self) -> HeadTape:
def to_ptr(self) -> PtrTape:
return PtrTape(
sum(int(q.count) for q in self.lspan) - self.head,
self.scan,
self.unroll(),
)

Expand All @@ -81,6 +82,7 @@ def step(self, shift: Shift, color: Color, skip: bool) -> int:
@dataclass
class PtrTape:
init: int
scan: Color
tape: list[Color]

def get_ltr(self, start: int) -> TapeSlice:
Expand Down Expand Up @@ -354,6 +356,9 @@ def run(self, sim_lim: int) -> Self: # no-cover
if state != init_state:
continue

if tape.scan != init_tape.scan:
continue

ptr = tape.to_ptr()

if 0 < (diff := tape.head - init_pos):
Expand Down

0 comments on commit 78fe82a

Please sign in to comment.