feed cell viability tuple
This commit is contained in:
parent
bddb770ef6
commit
f696952488
1 changed files with 6 additions and 2 deletions
|
@ -190,7 +190,7 @@ static class Mono
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Feed()
|
static (bool, XYZi) Feed()
|
||||||
{
|
{
|
||||||
// [!] handle out of the box exception on tail
|
// [!] handle out of the box exception on tail
|
||||||
// by making the spatial arrays encapsulate the layer outside of the box
|
// by making the spatial arrays encapsulate the layer outside of the box
|
||||||
|
@ -199,6 +199,7 @@ static class Mono
|
||||||
|
|
||||||
// step from head using directions towards the tail
|
// 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
|
// and stop at either 1 cell away from the tail or 5 spaces away from the head
|
||||||
|
bool viable = false;
|
||||||
XYZi cell = snake[0];
|
XYZi cell = snake[0];
|
||||||
for (int step = 0; step < 5; step++)
|
for (int step = 0; step < 5; step++)
|
||||||
{
|
{
|
||||||
|
@ -214,6 +215,7 @@ static class Mono
|
||||||
{
|
{
|
||||||
min_dist = tail_dist;
|
min_dist = tail_dist;
|
||||||
min_cell = dir_cell;
|
min_cell = dir_cell;
|
||||||
|
viable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cell = min_cell;
|
cell = min_cell;
|
||||||
|
@ -223,7 +225,9 @@ static class Mono
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
food = cell;
|
// [!] if can't find a viable cell try again next step
|
||||||
|
// (as it is possible to fence in the tail esp if you are eating)
|
||||||
|
return (viable, cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
// space fill algorithm
|
// space fill algorithm
|
||||||
|
|
Loading…
Add table
Reference in a new issue