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 86ef363d3b - Show all commits

View File

@ -255,8 +255,8 @@ class Bot {
return next;
}
autoplay() {
if (this.path.length > 0)
pathRefresh() {
if (this.path.length !== 0)
return;
this.bfs();
this.trim();
@ -273,14 +273,14 @@ function snakeloop() {
if (g_snake.gameover)
g_snake.reset();
// Input
g_snakebot.autoplay();
g_snake.simulate();
// Regenerate food if needed
g_snake.foodRegen();
// Get new path to food
g_snakebot.pathRefresh();
g_snake.draw();
}