diff --git a/src/Mono.cs b/src/Mono.cs index 973eadd..4bdb1fd 100644 --- a/src/Mono.cs +++ b/src/Mono.cs @@ -212,9 +212,11 @@ static class Mono // step from head using directions towards the tail // and stop at either 1 cell away from the tail or 5 spaces away from the head bool viable = false; + bool viable_step = false; XYZi cell = snake[0]; for (int step = 0; step < 5; step++) { + viable_step = false; int min_dist = 100; XYZi min_cell = new(); int[] dir_indices = GetShuffledIndices(directions); @@ -228,9 +230,13 @@ static class Mono min_dist = tail_dist; min_cell = dir_cell; viable = true; + viable_step = true; } } - cell = min_cell; + if (viable_step) + { + cell = min_cell; + } // if (min_dist <= 1) // { // break;