From 0021de31fbf0478668b898673c63c736c23216cb Mon Sep 17 00:00:00 2001 From: Vidya Date: Wed, 14 Apr 2021 15:35:08 -0400 Subject: [PATCH] don't tuck over empty locations --- ak-trace_graph.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ak-trace_graph.cpp b/ak-trace_graph.cpp index 926e72c..b6fe5f2 100644 --- a/ak-trace_graph.cpp +++ b/ak-trace_graph.cpp @@ -340,15 +340,21 @@ void ak::trace_graph( } - if (next != -1U) { - std::cout << " TUCKING[2] at " << next << " which has " << info[next].knits << " knits." << std::endl; + + if (next != -1U && info[next].knits) + { + //tuck 'next', turn, knit 'up': + if (next != -1U) tuck(next); + dir = (dir == Forward ? Backward : Forward); + if (next != -1U) miss(next); + knit(up); + } + else { + // don't tuck on an empty location + next = -1U; + dir = (dir == Forward ? Backward : Forward); + knit(up); } - - //tuck 'next', turn, knit 'up': - if (next != -1U) tuck(next); - dir = (dir == Forward ? Backward : Forward); - if (next != -1U) miss(next); - knit(up); return true; };