:roclet: improve algorithm, add an intermediate phase to clean up residual cell from previous layer, before grabing the free ones

This commit is contained in:
platane
2020-10-26 00:18:50 +01:00
parent 69c3551cc5
commit a3f590a7d2
13 changed files with 565 additions and 21 deletions

View File

@@ -0,0 +1,12 @@
import { createEmptyGrid } from "@snk/types/grid";
import { getHeadX, getHeadY } from "@snk/types/snake";
import { snake3 } from "@snk/types/__fixtures__/snake";
import { getPathTo } from "../getPathTo";
it("should find it's way in vaccum", () => {
const grid = createEmptyGrid(5, 0);
const path = getPathTo(grid, snake3, 5, -1)!;
expect([getHeadX(path[0]), getHeadY(path[0])]).toEqual([5, -1]);
});