From b6fe6783678347d1153eaf4c1d043e9ed01b1ee5 Mon Sep 17 00:00:00 2001 From: Trianta <56975502+Trimutex@users.noreply.github.com> Date: Sat, 9 Nov 2024 01:20:05 -0600 Subject: [PATCH] snake: add snake, but ignore when counting length left --- src/snake.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/snake.ts b/src/snake.ts index 740564a..258cb0f 100644 --- a/src/snake.ts +++ b/src/snake.ts @@ -214,6 +214,7 @@ 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; @@ -240,7 +241,7 @@ class Bot { */ nextMove() { // Get new path to food - if (this.path.length !== 0) + if (this.path.length === 1) this.pathRefresh(); var next: Point = new Point; next.copy(this.path.pop());