snake: fix snake body skipping placement half the time
This commit is contained in:
parent
f975b0a045
commit
8e626448a2
12
src/snake.ts
12
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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user