around box check

This commit is contained in:
ethan merchant 2024-11-08 21:52:45 -05:00
parent 5855e4a5d0
commit 284f6e9b23

View file

@ -89,6 +89,32 @@ static class Mono
return; 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) if (snake_len == snake.Length)
{ {
// win condition // win condition