snake: not adding last piece was correct, bool check was not

This commit is contained in:
Trianta 2024-11-09 01:23:11 -06:00
parent b6fe678367
commit 3699ed465b

View File

@ -214,7 +214,6 @@ class Bot {
continue; continue;
if (isBitSet(g_snake.board[location.y][location.x], BoardState.SNAKE)) { if (isBitSet(g_snake.board[location.y][location.x], BoardState.SNAKE)) {
reachedSnake = true; reachedSnake = true;
this.path.push(location);
continue; continue;
} }
var delta = new Point; var delta = new Point;
@ -241,7 +240,7 @@ class Bot {
*/ */
nextMove() { nextMove() {
// Get new path to food // Get new path to food
if (this.path.length === 1) if (this.path.length === 0)
this.pathRefresh(); this.pathRefresh();
var next: Point = new Point; var next: Point = new Point;
next.copy(this.path.pop()); next.copy(this.path.pop());