🚀 benchmark

This commit is contained in:
platane
2020-07-21 18:15:41 +02:00
parent 1898ec16e4
commit e637604df1
13 changed files with 182 additions and 61 deletions

View File

@@ -80,12 +80,9 @@ const unwrap = (c: ReturnType<typeof createCell> | null): Point[] =>
export const computeBestRun = (
grid0: Grid,
snake0: Snake,
options: { maxSnakeLength: number; colors: Color[] }
options: { maxSnakeLength: number; colors: Color[] },
u = 8000
) => {
// const grid = copyGrid(grid0);
// const snake = copySnake(snake0);
// const stack: Color[] = [];
const computeHeuristic = createComputeHeuristic(
grid0,
snake0,
@@ -104,8 +101,6 @@ export const computeBestRun = (
),
];
let u = 8000;
let best = openList[0];
while (openList.length && u-- > 0) {
@@ -147,28 +142,4 @@ export const computeBestRun = (
}
return unwrap(best);
// while (!isGridEmpty(g) && u-- > 0) {
// let direction;
// for (let k = 10; k--; ) {
// direction = around4[Math.floor(Math.random() * around4.length)];
// const sn = copySnake(s);
// stepSnake(sn, direction, options);
// if (isInsideLarge(g, 1, sn[0].x, sn[0].y) && !snakeSelfCollide(sn)) {
// break;
// } else {
// direction = undefined;
// }
// }
// if (direction !== undefined) {
// step(g, s, q, direction, options);
// commands.push(direction);
// }
// }
// return commands;
};