From 284f6e9b23da6c67be6dd342fbc8c8b09af68a53 Mon Sep 17 00:00:00 2001 From: spatialfree Date: Fri, 8 Nov 2024 21:52:45 -0500 Subject: [PATCH] around box check --- src/Mono.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/Mono.cs b/src/Mono.cs index fca97db..a60c14b 100644 --- a/src/Mono.cs +++ b/src/Mono.cs @@ -89,6 +89,32 @@ static class Mono return; } + XYZi next_pos = snake[0] + snake_dir; + bool around_box = false; + for (int i = 0; i < directions.Length; i++) + { + if (s_array.InRange(next_pos + directions[i])) + { + around_box = true; + break; + } + } + if (!around_box) + { + for (int i = 0; i < corners.Length; i++) + { + if (s_array.InRange(next_pos + corners[i])) + { + around_box = true; + break; + } + } + } + if (!around_box) + { + return; + } + if (snake_len == snake.Length) { // win condition