around box check
This commit is contained in:
parent
5855e4a5d0
commit
284f6e9b23
1 changed files with 26 additions and 0 deletions
26
src/Mono.cs
26
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
|
||||
|
|
Loading…
Add table
Reference in a new issue