From 8e626448a2079123749298e4c1e1c47ba153bf4e Mon Sep 17 00:00:00 2001 From: Trianta <56975502+Trimutex@users.noreply.github.com> Date: Sun, 1 Sep 2024 05:05:49 -0500 Subject: [PATCH] snake: fix snake body skipping placement half the time --- src/snake.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/snake.ts b/src/snake.ts index d5781a5..794528c 100644 --- a/src/snake.ts +++ b/src/snake.ts @@ -259,12 +259,11 @@ class Bot { } autoplay() { - if (this.path.length === 0) { - this.bfs(); - this.trim(); - this.unvisit(); - } - return this.nextMove(); + if (this.path.length > 0) + return; + this.bfs(); + this.trim(); + this.unvisit(); } } @@ -276,6 +275,7 @@ function snakeloop() { // Reset of needed if (snake.gameover) snake.reset(); + // Input bot.autoplay();