🔨 rename package compute -> solver
This commit is contained in:
@@ -39,3 +39,7 @@ npm install
|
|||||||
|
|
||||||
npm run dev:demo
|
npm run dev:demo
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Implementation
|
||||||
|
|
||||||
|
[solver algorithm](./packages/solver/README.md)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { getGithubUserContribution } from "@snk/github-user-contribution";
|
import { getGithubUserContribution } from "@snk/github-user-contribution";
|
||||||
import { userContributionToGrid } from "./userContributionToGrid";
|
import { userContributionToGrid } from "./userContributionToGrid";
|
||||||
import { getBestRoute } from "@snk/compute/getBestRoute";
|
import { getBestRoute } from "@snk/solver/getBestRoute";
|
||||||
import { createGif } from "@snk/gif-creator";
|
import { createGif } from "@snk/gif-creator";
|
||||||
import { createSvg } from "../svg-creator";
|
import { createSvg } from "../svg-creator";
|
||||||
import { snake4 } from "@snk/types/__fixtures__/snake";
|
import { snake4 } from "@snk/types/__fixtures__/snake";
|
||||||
import { getPathToPose } from "@snk/compute/getPathToPose";
|
import { getPathToPose } from "@snk/solver/getPathToPose";
|
||||||
|
|
||||||
export const generateContributionSnake = async (
|
export const generateContributionSnake = async (
|
||||||
userName: string,
|
userName: string,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import "./menu";
|
import "./menu";
|
||||||
import { createCanvas } from "./canvas";
|
import { createCanvas } from "./canvas";
|
||||||
import { getBestRoute } from "@snk/compute/getBestRoute";
|
import { getBestRoute } from "@snk/solver/getBestRoute";
|
||||||
import { Color, copyGrid } from "@snk/types/grid";
|
import { Color, copyGrid } from "@snk/types/grid";
|
||||||
import { grid, snake } from "./sample";
|
import { grid, snake } from "./sample";
|
||||||
import { step } from "@snk/compute/step";
|
import { step } from "@snk/solver/step";
|
||||||
|
|
||||||
const chain = getBestRoute(grid, snake)!;
|
const chain = getBestRoute(grid, snake)!;
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import { createCanvas } from "./canvas";
|
|||||||
import { getSnakeLength } from "@snk/types/snake";
|
import { getSnakeLength } from "@snk/types/snake";
|
||||||
import { grid, snake } from "./sample";
|
import { grid, snake } from "./sample";
|
||||||
import { getColor } from "@snk/types/grid";
|
import { getColor } from "@snk/types/grid";
|
||||||
import { getBestTunnel } from "@snk/compute/getBestTunnel";
|
import { getBestTunnel } from "@snk/solver/getBestTunnel";
|
||||||
import { createOutside } from "@snk/compute/outside";
|
import { createOutside } from "@snk/solver/outside";
|
||||||
import type { Color } from "@snk/types/grid";
|
import type { Color } from "@snk/types/grid";
|
||||||
import type { Point } from "@snk/types/point";
|
import type { Point } from "@snk/types/point";
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import "./menu";
|
|||||||
import { createCanvas } from "./canvas";
|
import { createCanvas } from "./canvas";
|
||||||
import { copySnake, snakeToCells } from "@snk/types/snake";
|
import { copySnake, snakeToCells } from "@snk/types/snake";
|
||||||
import { grid, snake as snake0 } from "./sample";
|
import { grid, snake as snake0 } from "./sample";
|
||||||
import { getPathTo } from "@snk/compute/getPathTo";
|
import { getPathTo } from "@snk/solver/getPathTo";
|
||||||
|
|
||||||
const { canvas, ctx, draw, getPointedCell, highlightCell } = createCanvas(grid);
|
const { canvas, ctx, draw, getPointedCell, highlightCell } = createCanvas(grid);
|
||||||
canvas.style.pointerEvents = "auto";
|
canvas.style.pointerEvents = "auto";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import "./menu";
|
|||||||
import { createCanvas } from "./canvas";
|
import { createCanvas } from "./canvas";
|
||||||
import { createSnakeFromCells, snakeToCells } from "@snk/types/snake";
|
import { createSnakeFromCells, snakeToCells } from "@snk/types/snake";
|
||||||
import { grid, snake } from "./sample";
|
import { grid, snake } from "./sample";
|
||||||
import { getPathToPose } from "@snk/compute/getPathToPose";
|
import { getPathToPose } from "@snk/solver/getPathToPose";
|
||||||
|
|
||||||
const { canvas, ctx, draw, highlightCell } = createCanvas(grid);
|
const { canvas, ctx, draw, highlightCell } = createCanvas(grid);
|
||||||
canvas.style.pointerEvents = "auto";
|
canvas.style.pointerEvents = "auto";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { getBestRoute } from "@snk/compute/getBestRoute";
|
import { getBestRoute } from "@snk/solver/getBestRoute";
|
||||||
import { Color, copyGrid, Grid } from "@snk/types/grid";
|
import { Color, copyGrid, Grid } from "@snk/types/grid";
|
||||||
import { step } from "@snk/compute/step";
|
import { step } from "@snk/solver/step";
|
||||||
import { isStableAndBound, stepSpring } from "./springUtils";
|
import { isStableAndBound, stepSpring } from "./springUtils";
|
||||||
import { Res } from "@snk/github-user-contribution";
|
import { Res } from "@snk/github-user-contribution";
|
||||||
import { Snake } from "@snk/types/snake";
|
import { Snake } from "@snk/types/snake";
|
||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
} from "@snk/draw/drawWorld";
|
} from "@snk/draw/drawWorld";
|
||||||
import { userContributionToGrid } from "../action/userContributionToGrid";
|
import { userContributionToGrid } from "../action/userContributionToGrid";
|
||||||
import { snake4 as snake } from "@snk/types/__fixtures__/snake";
|
import { snake4 as snake } from "@snk/types/__fixtures__/snake";
|
||||||
import { getPathToPose } from "@snk/compute/getPathToPose";
|
import { getPathToPose } from "@snk/solver/getPathToPose";
|
||||||
import { createSvg } from "../svg-creator";
|
import { createSvg } from "../svg-creator";
|
||||||
|
|
||||||
const createForm = ({
|
const createForm = ({
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import "./menu";
|
|||||||
import { createCanvas } from "./canvas";
|
import { createCanvas } from "./canvas";
|
||||||
import { grid } from "./sample";
|
import { grid } from "./sample";
|
||||||
import type { Color } from "@snk/types/grid";
|
import type { Color } from "@snk/types/grid";
|
||||||
import { createOutside, isOutside } from "@snk/compute/outside";
|
import { createOutside, isOutside } from "@snk/solver/outside";
|
||||||
|
|
||||||
const { canvas, ctx, draw, highlightCell } = createCanvas(grid);
|
const { canvas, ctx, draw, highlightCell } = createCanvas(grid);
|
||||||
document.body.appendChild(canvas);
|
document.body.appendChild(canvas);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import "./menu";
|
import "./menu";
|
||||||
import { getBestRoute } from "@snk/compute/getBestRoute";
|
import { getBestRoute } from "@snk/solver/getBestRoute";
|
||||||
import { createSvg } from "../svg-creator";
|
import { createSvg } from "../svg-creator";
|
||||||
import { grid, snake } from "./sample";
|
import { grid, snake } from "./sample";
|
||||||
import { drawOptions } from "./canvas";
|
import { drawOptions } from "./canvas";
|
||||||
import { getPathToPose } from "@snk/compute/getPathToPose";
|
import { getPathToPose } from "@snk/solver/getPathToPose";
|
||||||
|
|
||||||
const chain = getBestRoute(grid, snake);
|
const chain = getBestRoute(grid, snake);
|
||||||
chain.push(...getPathToPose(chain.slice(-1)[0], snake)!);
|
chain.push(...getPathToPose(chain.slice(-1)[0], snake)!);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "@snk/demo",
|
"name": "@snk/demo",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@snk/compute": "1.0.0",
|
"@snk/solver": "1.0.0",
|
||||||
"@snk/draw": "1.0.0"
|
"@snk/draw": "1.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
"name": "@snk/draw",
|
"name": "@snk/draw",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@snk/compute": "1.0.0"
|
"@snk/solver": "1.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { createGif } from "..";
|
|||||||
import * as grids from "@snk/types/__fixtures__/grid";
|
import * as grids from "@snk/types/__fixtures__/grid";
|
||||||
import { snake3 as snake } from "@snk/types/__fixtures__/snake";
|
import { snake3 as snake } from "@snk/types/__fixtures__/snake";
|
||||||
import { createSnakeFromCells, nextSnake } from "@snk/types/snake";
|
import { createSnakeFromCells, nextSnake } from "@snk/types/snake";
|
||||||
import { getBestRoute } from "@snk/compute/getBestRoute";
|
import { getBestRoute } from "@snk/solver/getBestRoute";
|
||||||
|
|
||||||
jest.setTimeout(20 * 1000);
|
jest.setTimeout(20 * 1000);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
drawLerpWorld,
|
drawLerpWorld,
|
||||||
getCanvasWorldSize,
|
getCanvasWorldSize,
|
||||||
} from "@snk/draw/drawWorld";
|
} from "@snk/draw/drawWorld";
|
||||||
import { step } from "@snk/compute/step";
|
import { step } from "@snk/solver/step";
|
||||||
import tmp from "tmp";
|
import tmp from "tmp";
|
||||||
import execa from "execa";
|
import execa from "execa";
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "@snk/gif-creator",
|
"name": "@snk/gif-creator",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@snk/compute": "1.0.0",
|
"@snk/solver": "1.0.0",
|
||||||
"@snk/draw": "1.0.0",
|
"@snk/draw": "1.0.0",
|
||||||
"canvas": "2.6.1",
|
"canvas": "2.6.1",
|
||||||
"execa": "4.1.0",
|
"execa": "4.1.0",
|
||||||
|
|||||||
@@ -3,20 +3,6 @@
|
|||||||
exports[`should match snapshot for year=2019 1`] = `
|
exports[`should match snapshot for year=2019 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"cells": Array [
|
"cells": Array [
|
||||||
Object {
|
|
||||||
"color": "#9be9a8",
|
|
||||||
"count": 4,
|
|
||||||
"date": "2018-12-30",
|
|
||||||
"x": 0,
|
|
||||||
"y": 0,
|
|
||||||
},
|
|
||||||
Object {
|
|
||||||
"color": "#9be9a8",
|
|
||||||
"count": 1,
|
|
||||||
"date": "2018-12-31",
|
|
||||||
"x": 0,
|
|
||||||
"y": 1,
|
|
||||||
},
|
|
||||||
Object {
|
Object {
|
||||||
"color": "#ebedf0",
|
"color": "#ebedf0",
|
||||||
"count": 0,
|
"count": 0,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# @snk/compute
|
# @snk/solver
|
||||||
|
|
||||||
Contains the algorithm to compute the best route given a grid and a starting position for the snake.
|
Contains the algorithm to compute the best route given a grid and a starting position for the snake.
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "@snk/compute",
|
"name": "@snk/solver",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"park-miller": "1.1.0"
|
"park-miller": "1.1.0"
|
||||||
@@ -3,7 +3,7 @@ import * as path from "path";
|
|||||||
import { createSvg } from "..";
|
import { createSvg } from "..";
|
||||||
import * as grids from "@snk/types/__fixtures__/grid";
|
import * as grids from "@snk/types/__fixtures__/grid";
|
||||||
import { snake3 as snake } from "@snk/types/__fixtures__/snake";
|
import { snake3 as snake } from "@snk/types/__fixtures__/snake";
|
||||||
import { getBestRoute } from "@snk/compute/getBestRoute";
|
import { getBestRoute } from "@snk/solver/getBestRoute";
|
||||||
|
|
||||||
const drawOptions = {
|
const drawOptions = {
|
||||||
sizeBorderRadius: 2,
|
sizeBorderRadius: 2,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "@snk/svg-creator",
|
"name": "@snk/svg-creator",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@snk/compute": "1.0.0",
|
"@snk/solver": "1.0.0",
|
||||||
"csso": "4.2.0"
|
"csso": "4.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user