From 3699ed465b15adb30c8d2079cc8cf7dd6d74c531 Mon Sep 17 00:00:00 2001 From: Trianta <56975502+Trimutex@users.noreply.github.com> Date: Sat, 9 Nov 2024 01:23:11 -0600 Subject: [PATCH] snake: not adding last piece was correct, bool check was not --- src/snake.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/snake.ts b/src/snake.ts index 258cb0f..529befe 100644 --- a/src/snake.ts +++ b/src/snake.ts @@ -214,7 +214,6 @@ class Bot { continue; if (isBitSet(g_snake.board[location.y][location.x], BoardState.SNAKE)) { reachedSnake = true; - this.path.push(location); continue; } var delta = new Point; @@ -241,7 +240,7 @@ class Bot { */ nextMove() { // Get new path to food - if (this.path.length === 1) + if (this.path.length === 0) this.pathRefresh(); var next: Point = new Point; next.copy(this.path.pop());