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();