core: add Snake using Typescript #7

Merged
Trianta merged 35 commits from snake into main 2024-11-09 01:26:09 -06:00
Showing only changes of commit 8e626448a2 - Show all commits

View File

@ -259,13 +259,12 @@ class Bot {
}
autoplay() {
if (this.path.length === 0) {
if (this.path.length > 0)
return;
this.bfs();
this.trim();
this.unvisit();
}
return this.nextMove();
}
}
const snake: SnakeCore = new SnakeCore(); // Singleton for snake game
@ -276,6 +275,7 @@ function snakeloop() {
// Reset of needed
if (snake.gameover)
snake.reset();
// Input
bot.autoplay();