scrabble-solver 2.16.6 → 2.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/bunx.yml +26 -2
- package/.github/workflows/npx.yml +26 -2
- package/.nx/workspace-data/d/server-process.json +3 -3
- package/.nx/workspace-data/file-map.json +441 -465
- package/.nx/workspace-data/lockfile-dependencies.hash +1 -1
- package/.nx/workspace-data/lockfile-nodes.hash +1 -1
- package/.nx/workspace-data/nx_files.nxt +0 -0
- package/.nx/workspace-data/parsed-lock-file.dependencies.json +2671 -2121
- package/.nx/workspace-data/parsed-lock-file.nodes.json +3846 -5277
- package/.nx/workspace-data/project-graph.json +7089 -7924
- package/.nx/workspace-data/source-maps.json +351 -255
- package/.oxlintrc.json +6 -0
- package/CLAUDE.md +25 -20
- package/README.md +9 -0
- package/bun.lock +1054 -2897
- package/bunfig.toml +6 -0
- package/cypress/e2e/app.spec.cy.ts +4 -4
- package/cypress/e2e/features/solver-paths.ts +66 -0
- package/cypress/e2e/features.spec.cy.ts +1 -0
- package/cypress/support/lib/actions.ts +28 -9
- package/cypress.config.ts +7 -0
- package/lerna.json +1 -1
- package/nx.json +3 -1
- package/package.json +18 -18
- package/packages/configs/package.json +4 -4
- package/packages/constants/package.json +2 -2
- package/packages/dictionaries/README.md +1 -1
- package/packages/dictionaries/build/Dictionaries.d.ts +2 -2
- package/packages/dictionaries/build/Dictionaries.js +6 -6
- package/packages/dictionaries/build/lib/DiskCache.d.ts +11 -4
- package/packages/dictionaries/build/lib/DiskCache.js +27 -10
- package/packages/dictionaries/build/lib/LayeredCache.d.ts +4 -4
- package/packages/dictionaries/build/lib/LayeredCache.js +3 -3
- package/packages/dictionaries/build/lib/MemoryCache.d.ts +4 -4
- package/packages/dictionaries/build/lib/MemoryCache.js +2 -2
- package/packages/dictionaries/build/lib/createCacheTimestampComparator.d.ts +2 -2
- package/packages/dictionaries/build/lib/downloadDictionary.d.ts +2 -2
- package/packages/dictionaries/build/lib/downloadDictionary.js +4 -3
- package/packages/dictionaries/build/lib/getDictionaryFilepath.d.ts +3 -1
- package/packages/dictionaries/build/lib/getDictionaryFilepath.js +8 -3
- package/packages/dictionaries/package.json +8 -7
- package/packages/dictionaries/src/Dictionaries.ts +12 -12
- package/packages/dictionaries/src/lib/DiskCache.test.ts +85 -0
- package/packages/dictionaries/src/lib/DiskCache.ts +34 -14
- package/packages/dictionaries/src/lib/LayeredCache.ts +7 -7
- package/packages/dictionaries/src/lib/MemoryCache.ts +6 -6
- package/packages/dictionaries/src/lib/createCacheTimestampComparator.ts +2 -2
- package/packages/dictionaries/src/lib/downloadDictionary.ts +5 -4
- package/packages/dictionaries/src/lib/getDictionaryFilepath.ts +7 -2
- package/packages/gaddag/build/Gaddag.d.ts +39 -0
- package/packages/gaddag/build/Gaddag.js +128 -0
- package/packages/gaddag/build/buildGaddag.d.ts +10 -0
- package/packages/gaddag/build/buildGaddag.js +360 -0
- package/packages/gaddag/build/constants.d.ts +12 -0
- package/packages/gaddag/build/constants.js +15 -0
- package/packages/gaddag/build/index.d.ts +3 -0
- package/packages/gaddag/build/index.js +13 -0
- package/packages/logger/package.json +2 -2
- package/packages/scrabble-solver/.next/BUILD_ID +1 -1
- package/packages/scrabble-solver/.next/build-manifest.json +17 -17
- package/packages/scrabble-solver/.next/cache/.previewinfo +1 -1
- package/packages/scrabble-solver/.next/cache/.rscinfo +1 -1
- package/packages/scrabble-solver/.next/cache/.tsbuildinfo +1 -1
- package/packages/scrabble-solver/.next/cache/webpack/client-production/0.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/client-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/client-production/index.pack.old +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/index.pack.old +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/0.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack.old +0 -0
- package/packages/scrabble-solver/.next/diagnostics/framework.json +1 -1
- package/packages/scrabble-solver/.next/next-minimal-server.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/next-server.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/prerender-manifest.json +7 -4
- package/packages/scrabble-solver/.next/required-server-files.js +29 -10
- package/packages/scrabble-solver/.next/required-server-files.json +29 -10
- package/packages/scrabble-solver/.next/routes-manifest.json +1 -1
- package/packages/scrabble-solver/.next/server/chunks/129.js +1 -0
- package/packages/scrabble-solver/.next/server/chunks/30.js +2 -2
- package/packages/scrabble-solver/.next/server/chunks/318.js +3 -3
- package/packages/scrabble-solver/.next/server/chunks/392.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/671.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/712.js +1 -1
- package/packages/scrabble-solver/.next/server/chunks/785.js +1 -0
- package/packages/scrabble-solver/.next/server/chunks/791.js +3 -3
- package/packages/scrabble-solver/.next/server/middleware-build-manifest.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/404.html +1 -1
- package/packages/scrabble-solver/.next/server/pages/500.html +1 -1
- package/packages/scrabble-solver/.next/server/pages/_app.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/_app.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/_document.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/_error.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/_error.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale]/[word].js +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale]/[word].js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale].js +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale].js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/solve.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/solve.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/verify.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/verify.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/visit.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/visit.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/index.html +1 -1
- package/packages/scrabble-solver/.next/server/pages/index.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/index.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/index.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/not-found.html +1 -1
- package/packages/scrabble-solver/.next/server/pages/not-found.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages-manifest.json +1 -1
- package/packages/scrabble-solver/.next/server/webpack-runtime.js +1 -1
- package/packages/scrabble-solver/.next/static/{js6-w0PwySs2PyOSeCYfi → OLE8_ZInlGH7ENU0NIOpf}/_buildManifest.js +1 -1
- package/packages/scrabble-solver/.next/static/chunks/583.7a46807be14c377e.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/830.661816bf0de8c2f1.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/framework-3cf15b8041c59dd3.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/main-5b999f3f24ebfa84.js +5 -0
- package/packages/scrabble-solver/.next/static/chunks/pages/_app-7024e7a27ffbb2fa.js +7 -0
- package/packages/scrabble-solver/.next/static/chunks/pages/{index-bdf5e1e44cea16f6.js → index-8b398b0a5d870773.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/webpack-3943d624bbb47a64.js +1 -0
- package/packages/scrabble-solver/.next/static/css/aedeaada218d7280.css +2 -0
- package/packages/scrabble-solver/.next/trace +21 -21
- package/packages/scrabble-solver/.next/trace-build +1 -1
- package/packages/scrabble-solver/.next/types/cache-life.d.ts +1 -0
- package/packages/scrabble-solver/.next/types/root-params.d.ts +3 -0
- package/packages/scrabble-solver/next-env.d.ts +1 -0
- package/packages/scrabble-solver/next.config.js +0 -1
- package/packages/scrabble-solver/package.json +19 -19
- package/packages/scrabble-solver/public/service-worker.js +2 -2
- package/packages/scrabble-solver/public/service-worker.js.map +1 -1
- package/packages/scrabble-solver/src/components/Board/components/Cell/Cell.tsx +4 -1
- package/packages/scrabble-solver/src/components/Board/hooks/useGrid.ts +17 -6
- package/packages/scrabble-solver/src/components/Dictionary/Dictionary.module.scss +7 -22
- package/packages/scrabble-solver/src/components/Dictionary/Dictionary.tsx +1 -8
- package/packages/scrabble-solver/src/components/Results/Result.tsx +0 -3
- package/packages/scrabble-solver/src/components/Results/Results.module.scss +0 -1
- package/packages/scrabble-solver/src/components/Results/Results.tsx +10 -2
- package/packages/scrabble-solver/src/components/Results/types.ts +3 -3
- package/packages/scrabble-solver/src/components/Solver/Solver.tsx +4 -3
- package/packages/scrabble-solver/src/components/Tooltip/useTooltip.ts +1 -1
- package/packages/scrabble-solver/src/pages/api/dictionary/[locale]/[word].ts +2 -2
- package/packages/scrabble-solver/src/pages/api/dictionary/[locale]/index.ts +80 -3
- package/packages/scrabble-solver/src/pages/api/solve.ts +2 -2
- package/packages/scrabble-solver/src/pages/api/verify.ts +12 -3
- package/packages/scrabble-solver/src/sdk/solve.ts +13 -7
- package/packages/scrabble-solver/src/sdk/verify.ts +12 -6
- package/packages/scrabble-solver/src/service-worker/appShell.test.ts +86 -0
- package/packages/scrabble-solver/src/service-worker/appShell.ts +39 -0
- package/packages/scrabble-solver/src/service-worker/index.ts +4 -5
- package/packages/scrabble-solver/src/serviceWorkerManager.ts +1 -18
- package/packages/scrabble-solver/src/solver-worker/client.test.ts +151 -0
- package/packages/scrabble-solver/src/solver-worker/client.ts +106 -0
- package/packages/scrabble-solver/src/solver-worker/dictionaries/constants.ts +9 -0
- package/packages/scrabble-solver/src/solver-worker/dictionaries/getDictionary.ts +21 -0
- package/packages/scrabble-solver/src/solver-worker/dictionaries/index.ts +2 -0
- package/packages/scrabble-solver/src/solver-worker/dictionaries/revalidateDictionary.test.ts +199 -0
- package/packages/scrabble-solver/src/solver-worker/dictionaries/revalidateDictionary.ts +86 -0
- package/packages/scrabble-solver/src/solver-worker/dictionaries/revalidatedAt.ts +43 -0
- package/packages/scrabble-solver/src/solver-worker/getGaddag.test.ts +109 -0
- package/packages/scrabble-solver/src/solver-worker/getGaddag.ts +62 -0
- package/packages/scrabble-solver/src/solver-worker/index.ts +1 -0
- package/packages/scrabble-solver/src/solver-worker/index.worker.ts +124 -0
- package/packages/scrabble-solver/src/solver-worker/messages.ts +20 -0
- package/packages/scrabble-solver/src/state/index.ts +1 -0
- package/packages/scrabble-solver/src/state/sagas.ts +19 -9
- package/packages/scrabble-solver/src/state/useTypedStore.ts +6 -0
- package/packages/scrabble-solver/src/types/api.ts +1 -2
- package/packages/scrabble-solver/tsconfig.json +4 -0
- package/packages/scrabble-solver/tsconfig.tsbuildinfo +1 -1
- package/packages/solver/README.md +24 -0
- package/packages/solver/benchmarks/index.ts +15 -0
- package/packages/solver/benchmarks/lib.ts +31 -0
- package/packages/solver/benchmarks/renderChart.ts +165 -0
- package/packages/solver/benchmarks/results/chart.svg +65 -0
- package/packages/solver/benchmarks/runBenchmarks.ts +66 -0
- package/packages/solver/benchmarks/scenarios.ts +64 -0
- package/packages/solver/benchmarks/types.ts +16 -0
- package/packages/solver/benchmarks/updateReadme.ts +53 -0
- package/packages/solver/build/MoveGenerator.d.ts +116 -0
- package/packages/solver/build/MoveGenerator.js +686 -0
- package/packages/solver/build/index.d.ts +0 -13
- package/packages/solver/build/index.js +1 -27
- package/packages/solver/build/solve.d.ts +2 -2
- package/packages/solver/build/solve.js +3 -19
- package/packages/solver/package.json +8 -7
- package/packages/solver/src/MoveGenerator.test.ts +1009 -0
- package/packages/solver/src/MoveGenerator.ts +926 -0
- package/packages/solver/src/ReferenceSolver.ts +401 -0
- package/packages/solver/src/index.ts +0 -13
- package/packages/solver/src/solve.test.ts +21 -21
- package/packages/solver/src/solve.ts +4 -22
- package/packages/solver/tsconfig.json +1 -1
- package/packages/types/build/Cell.d.ts +1 -0
- package/packages/types/build/Cell.js +3 -0
- package/packages/types/build/Result.d.ts +3 -2
- package/packages/types/build/Result.js +11 -6
- package/packages/types/build/ResultJson.d.ts +5 -4
- package/packages/types/build/index.d.ts +0 -6
- package/packages/types/build/index.js +1 -9
- package/packages/types/build/readResultCells.d.ts +5 -0
- package/packages/types/build/readResultCells.js +75 -0
- package/packages/types/package.json +5 -4
- package/packages/types/src/Cell.ts +4 -0
- package/packages/types/src/Result.ts +15 -6
- package/packages/types/src/ResultJson.ts +5 -5
- package/packages/types/src/index.ts +0 -6
- package/packages/types/src/readResultCells.test.ts +140 -0
- package/packages/types/src/readResultCells.ts +90 -0
- package/packages/word-definitions/package.json +3 -3
- package/packages/word-lists/package.json +4 -4
- package/packages/scrabble-solver/.next/static/chunks/framework-a23f7f643b59a2ca.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/main-92448bb08bb6bf1f.js +0 -5
- package/packages/scrabble-solver/.next/static/chunks/pages/_app-4ae86f006f6b9fe7.js +0 -7
- package/packages/scrabble-solver/.next/static/chunks/webpack-1a7a166b34ed8d24.js +0 -1
- package/packages/scrabble-solver/.next/static/css/0af35adb4bab56f0.css +0 -2
- package/packages/scrabble-solver/src/sdk/getDictionary.ts +0 -9
- package/packages/scrabble-solver/src/service-worker/average.ts +0 -7
- package/packages/scrabble-solver/src/service-worker/dictionaries/constants.ts +0 -5
- package/packages/scrabble-solver/src/service-worker/dictionaries/getDictionary.ts +0 -20
- package/packages/scrabble-solver/src/service-worker/dictionaries/index.ts +0 -2
- package/packages/scrabble-solver/src/service-worker/dictionaries/revalidateDictionary.ts +0 -33
- package/packages/scrabble-solver/src/service-worker/getTrie.ts +0 -24
- package/packages/scrabble-solver/src/service-worker/routeSolveRequests.ts +0 -91
- package/packages/scrabble-solver/src/service-worker/routeVerifyRequests.ts +0 -37
- package/packages/solver/build/areDigraphsValid.d.ts +0 -2
- package/packages/solver/build/areDigraphsValid.js +0 -17
- package/packages/solver/build/fillPattern.d.ts +0 -6
- package/packages/solver/build/fillPattern.js +0 -52
- package/packages/solver/build/generateEndIndices.d.ts +0 -2
- package/packages/solver/build/generateEndIndices.js +0 -17
- package/packages/solver/build/generateHorizontalPatterns.d.ts +0 -2
- package/packages/solver/build/generateHorizontalPatterns.js +0 -16
- package/packages/solver/build/generatePattern.d.ts +0 -7
- package/packages/solver/build/generatePattern.js +0 -20
- package/packages/solver/build/generatePatterns.d.ts +0 -2
- package/packages/solver/build/generatePatterns.js +0 -11
- package/packages/solver/build/generateStartIndices.d.ts +0 -2
- package/packages/solver/build/generateStartIndices.js +0 -16
- package/packages/solver/build/generateVectors.d.ts +0 -7
- package/packages/solver/build/generateVectors.js +0 -7
- package/packages/solver/build/generateVerticalPatterns.d.ts +0 -2
- package/packages/solver/build/generateVerticalPatterns.js +0 -16
- package/packages/solver/build/getCellsScore.d.ts +0 -2
- package/packages/solver/build/getCellsScore.js +0 -18
- package/packages/solver/build/getPatternHash.d.ts +0 -2
- package/packages/solver/build/getPatternHash.js +0 -14
- package/packages/solver/build/getPatternScore.d.ts +0 -2
- package/packages/solver/build/getPatternScore.js +0 -22
- package/packages/solver/build/getUniquePatterns.d.ts +0 -2
- package/packages/solver/build/getUniquePatterns.js +0 -17
- package/packages/solver/src/areDigraphsValid.ts +0 -18
- package/packages/solver/src/fillPattern.test.ts +0 -107
- package/packages/solver/src/fillPattern.ts +0 -68
- package/packages/solver/src/generateEndIndices.test.ts +0 -23
- package/packages/solver/src/generateEndIndices.ts +0 -19
- package/packages/solver/src/generateHorizontalPatterns.test.ts +0 -31
- package/packages/solver/src/generateHorizontalPatterns.ts +0 -15
- package/packages/solver/src/generatePattern.ts +0 -33
- package/packages/solver/src/generatePatterns.test.ts +0 -13
- package/packages/solver/src/generatePatterns.ts +0 -11
- package/packages/solver/src/generateStartIndices.test.ts +0 -19
- package/packages/solver/src/generateStartIndices.ts +0 -17
- package/packages/solver/src/generateVectors.test.ts +0 -12
- package/packages/solver/src/generateVectors.ts +0 -10
- package/packages/solver/src/generateVerticalPatterns.test.ts +0 -32
- package/packages/solver/src/generateVerticalPatterns.ts +0 -15
- package/packages/solver/src/getCellsScore.ts +0 -21
- package/packages/solver/src/getPatternHash.test.ts +0 -17
- package/packages/solver/src/getPatternHash.ts +0 -12
- package/packages/solver/src/getPatternScore.test.ts +0 -204
- package/packages/solver/src/getPatternScore.ts +0 -23
- package/packages/solver/src/getUniquePatterns.ts +0 -19
- package/packages/types/build/CollisionJson.d.ts +0 -2
- package/packages/types/build/CollisionJson.js +0 -2
- package/packages/types/build/FinalPattern.d.ts +0 -6
- package/packages/types/build/FinalPattern.js +0 -14
- package/packages/types/build/HorizontalPattern.d.ts +0 -5
- package/packages/types/build/HorizontalPattern.js +0 -34
- package/packages/types/build/Pattern.d.ts +0 -20
- package/packages/types/build/Pattern.js +0 -50
- package/packages/types/build/PatternJson.d.ts +0 -6
- package/packages/types/build/PatternJson.js +0 -2
- package/packages/types/build/VerticalPattern.d.ts +0 -5
- package/packages/types/build/VerticalPattern.js +0 -34
- package/packages/types/src/CollisionJson.ts +0 -3
- package/packages/types/src/FinalPattern.ts +0 -14
- package/packages/types/src/HorizontalPattern.ts +0 -37
- package/packages/types/src/Pattern.ts +0 -71
- package/packages/types/src/PatternJson.ts +0 -7
- package/packages/types/src/VerticalPattern.ts +0 -37
- /package/packages/scrabble-solver/.next/static/{js6-w0PwySs2PyOSeCYfi → OLE8_ZInlGH7ENU0NIOpf}/_ssgManifest.js +0 -0
- /package/packages/scrabble-solver/src/{service-worker → solver-worker}/dictionaries/expirationManager.ts +0 -0
- /package/packages/scrabble-solver/src/{service-worker → solver-worker}/dictionaries/getDictionaryUrl.ts +0 -0
|
@@ -8,25 +8,19 @@ export { Cell } from './Cell';
|
|
|
8
8
|
export { CellJson, isCellJson } from './CellJson';
|
|
9
9
|
export { CharacterBonus } from './CharacterBonus';
|
|
10
10
|
export { Collision } from './Collision';
|
|
11
|
-
export { CollisionJson } from './CollisionJson';
|
|
12
11
|
export { Config } from './Config';
|
|
13
12
|
export { ConfigJson } from './ConfigJson';
|
|
14
13
|
export { Dictionary } from './Dictionary';
|
|
15
|
-
export { FinalPattern } from './FinalPattern';
|
|
16
14
|
export { Game, isGame } from './Game';
|
|
17
|
-
export { HorizontalPattern } from './HorizontalPattern';
|
|
18
15
|
export { isError } from './isError';
|
|
19
16
|
export { isObject } from './isObject';
|
|
20
17
|
export { isLocale, Locale } from './Locale';
|
|
21
|
-
export { Pattern } from './Pattern';
|
|
22
|
-
export { PatternJson } from './PatternJson';
|
|
23
18
|
export { Result } from './Result';
|
|
24
19
|
export { ResultJson } from './ResultJson';
|
|
25
20
|
export { ShowCoordinates } from './ShowCoordinates';
|
|
26
21
|
export { Tile } from './Tile';
|
|
27
22
|
export { TileConfig } from './TileConfig';
|
|
28
23
|
export { isTileJson, TileJson } from './TileJson';
|
|
29
|
-
export { VerticalPattern } from './VerticalPattern';
|
|
30
24
|
export { WordBonus } from './WordBonus';
|
|
31
25
|
export { WordDefinition } from './WordDefinition';
|
|
32
26
|
export { WordDefinitionJson } from './WordDefinitionJson';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WordDefinition = exports.WordBonus = exports.
|
|
3
|
+
exports.WordDefinition = exports.WordBonus = exports.isTileJson = exports.Tile = exports.Result = exports.Locale = exports.isLocale = exports.isObject = exports.isError = exports.isGame = exports.Game = exports.Config = exports.CharacterBonus = exports.isCellJson = exports.Cell = exports.Bonus = exports.isBoardJson = exports.Board = exports.isScoreBingo = exports.isMultiplierBingo = exports.isBingo = void 0;
|
|
4
4
|
var Bingo_1 = require("./Bingo");
|
|
5
5
|
Object.defineProperty(exports, "isBingo", { enumerable: true, get: function () { return Bingo_1.isBingo; } });
|
|
6
6
|
Object.defineProperty(exports, "isMultiplierBingo", { enumerable: true, get: function () { return Bingo_1.isMultiplierBingo; } });
|
|
@@ -19,13 +19,9 @@ var CharacterBonus_1 = require("./CharacterBonus");
|
|
|
19
19
|
Object.defineProperty(exports, "CharacterBonus", { enumerable: true, get: function () { return CharacterBonus_1.CharacterBonus; } });
|
|
20
20
|
var Config_1 = require("./Config");
|
|
21
21
|
Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return Config_1.Config; } });
|
|
22
|
-
var FinalPattern_1 = require("./FinalPattern");
|
|
23
|
-
Object.defineProperty(exports, "FinalPattern", { enumerable: true, get: function () { return FinalPattern_1.FinalPattern; } });
|
|
24
22
|
var Game_1 = require("./Game");
|
|
25
23
|
Object.defineProperty(exports, "Game", { enumerable: true, get: function () { return Game_1.Game; } });
|
|
26
24
|
Object.defineProperty(exports, "isGame", { enumerable: true, get: function () { return Game_1.isGame; } });
|
|
27
|
-
var HorizontalPattern_1 = require("./HorizontalPattern");
|
|
28
|
-
Object.defineProperty(exports, "HorizontalPattern", { enumerable: true, get: function () { return HorizontalPattern_1.HorizontalPattern; } });
|
|
29
25
|
var isError_1 = require("./isError");
|
|
30
26
|
Object.defineProperty(exports, "isError", { enumerable: true, get: function () { return isError_1.isError; } });
|
|
31
27
|
var isObject_1 = require("./isObject");
|
|
@@ -33,16 +29,12 @@ Object.defineProperty(exports, "isObject", { enumerable: true, get: function ()
|
|
|
33
29
|
var Locale_1 = require("./Locale");
|
|
34
30
|
Object.defineProperty(exports, "isLocale", { enumerable: true, get: function () { return Locale_1.isLocale; } });
|
|
35
31
|
Object.defineProperty(exports, "Locale", { enumerable: true, get: function () { return Locale_1.Locale; } });
|
|
36
|
-
var Pattern_1 = require("./Pattern");
|
|
37
|
-
Object.defineProperty(exports, "Pattern", { enumerable: true, get: function () { return Pattern_1.Pattern; } });
|
|
38
32
|
var Result_1 = require("./Result");
|
|
39
33
|
Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return Result_1.Result; } });
|
|
40
34
|
var Tile_1 = require("./Tile");
|
|
41
35
|
Object.defineProperty(exports, "Tile", { enumerable: true, get: function () { return Tile_1.Tile; } });
|
|
42
36
|
var TileJson_1 = require("./TileJson");
|
|
43
37
|
Object.defineProperty(exports, "isTileJson", { enumerable: true, get: function () { return TileJson_1.isTileJson; } });
|
|
44
|
-
var VerticalPattern_1 = require("./VerticalPattern");
|
|
45
|
-
Object.defineProperty(exports, "VerticalPattern", { enumerable: true, get: function () { return VerticalPattern_1.VerticalPattern; } });
|
|
46
38
|
var WordBonus_1 = require("./WordBonus");
|
|
47
39
|
Object.defineProperty(exports, "WordBonus", { enumerable: true, get: function () { return WordBonus_1.WordBonus; } });
|
|
48
40
|
var WordDefinition_1 = require("./WordDefinition");
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Board } from './Board';
|
|
2
|
+
import { Cell } from './Cell';
|
|
3
|
+
import { type ResultJson } from './ResultJson';
|
|
4
|
+
export declare function readCells(json: ResultJson, board: Board): Cell[];
|
|
5
|
+
export declare function readCollisions(cells: Cell[], board: Board, isHorizontal: boolean): Cell[][];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readCells = readCells;
|
|
4
|
+
exports.readCollisions = readCollisions;
|
|
5
|
+
const Cell_1 = require("./Cell");
|
|
6
|
+
const Tile_1 = require("./Tile");
|
|
7
|
+
function readCells(json, board) {
|
|
8
|
+
const stepX = json.isHorizontal ? 1 : 0;
|
|
9
|
+
const stepY = json.isHorizontal ? 0 : 1;
|
|
10
|
+
const cells = [];
|
|
11
|
+
let placedIndex = 0;
|
|
12
|
+
let { x, y } = json;
|
|
13
|
+
while (y < board.rowsCount && x < board.columnsCount) {
|
|
14
|
+
const boardCell = board.rows[y][x];
|
|
15
|
+
if (boardCell.isFilled()) {
|
|
16
|
+
cells.push(boardCell.clone());
|
|
17
|
+
}
|
|
18
|
+
else if (placedIndex < json.tiles.length) {
|
|
19
|
+
cells.push(readPlacedCell(json, placedIndex, x, y));
|
|
20
|
+
placedIndex += 1;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
x += stepX;
|
|
26
|
+
y += stepY;
|
|
27
|
+
}
|
|
28
|
+
return cells;
|
|
29
|
+
}
|
|
30
|
+
function readCollisions(cells, board, isHorizontal) {
|
|
31
|
+
const collisions = [];
|
|
32
|
+
for (const cell of cells) {
|
|
33
|
+
if (cell.isFilled()) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const collision = readCollision(cell, board, isHorizontal);
|
|
37
|
+
if (collision.length > 1) {
|
|
38
|
+
collisions.push(collision);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return collisions;
|
|
42
|
+
}
|
|
43
|
+
function readPlacedCell(json, placedIndex, x, y) {
|
|
44
|
+
const character = json.tiles[placedIndex];
|
|
45
|
+
const isBlank = json.blankIndices.includes(placedIndex);
|
|
46
|
+
return new Cell_1.Cell({ isEmpty: true, tile: new Tile_1.Tile({ character, isBlank }), x, y });
|
|
47
|
+
}
|
|
48
|
+
function readCollision(placed, board, isHorizontal) {
|
|
49
|
+
const stepX = isHorizontal ? 0 : 1;
|
|
50
|
+
const stepY = isHorizontal ? 1 : 0;
|
|
51
|
+
let x = placed.x - stepX;
|
|
52
|
+
let y = placed.y - stepY;
|
|
53
|
+
while (x >= 0 && y >= 0 && board.rows[y][x].isFilled()) {
|
|
54
|
+
x -= stepX;
|
|
55
|
+
y -= stepY;
|
|
56
|
+
}
|
|
57
|
+
x += stepX;
|
|
58
|
+
y += stepY;
|
|
59
|
+
const collision = [];
|
|
60
|
+
while (y < board.rowsCount && x < board.columnsCount) {
|
|
61
|
+
if (x === placed.x && y === placed.y) {
|
|
62
|
+
collision.push(placed);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const boardCell = board.rows[y][x];
|
|
66
|
+
if (!boardCell.isFilled()) {
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
collision.push(boardCell.clone());
|
|
70
|
+
}
|
|
71
|
+
x += stepX;
|
|
72
|
+
y += stepY;
|
|
73
|
+
}
|
|
74
|
+
return collision;
|
|
75
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrabble-solver/types",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"description": "Scrabble Solver 2 - Types",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -19,11 +19,12 @@
|
|
|
19
19
|
},
|
|
20
20
|
"homepage": "https://scrabble-solver.org",
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "
|
|
23
|
-
"clean": "rimraf build/"
|
|
22
|
+
"build": "tsc --project .",
|
|
23
|
+
"clean": "rimraf build/",
|
|
24
|
+
"test": "bun test src"
|
|
24
25
|
},
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"@scrabble-solver/constants": "^2.
|
|
27
|
+
"@scrabble-solver/constants": "^2.17.0"
|
|
27
28
|
},
|
|
28
29
|
"gitHead": "1e2d1ad49a288d4a44196d8e3336740da132c637"
|
|
29
30
|
}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { CONSONANTS, VOWELS } from '@scrabble-solver/constants';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { type Board } from './Board';
|
|
4
|
+
import { type Cell } from './Cell';
|
|
5
|
+
import { readCells, readCollisions } from './readResultCells';
|
|
4
6
|
import { type ResultJson } from './ResultJson';
|
|
5
7
|
import { type Tile } from './Tile';
|
|
6
8
|
|
|
7
9
|
type Collision = Cell[];
|
|
8
10
|
|
|
9
11
|
export class Result {
|
|
10
|
-
public static fromJson = (json: ResultJson): Result => {
|
|
12
|
+
public static fromJson = (json: ResultJson, board: Board): Result => {
|
|
13
|
+
const cells = readCells(json, board);
|
|
14
|
+
|
|
11
15
|
return new Result({
|
|
16
|
+
cells,
|
|
17
|
+
collisions: readCollisions(cells, board, json.isHorizontal),
|
|
12
18
|
id: json.id,
|
|
13
|
-
cells: json.cells.map(Cell.fromJson),
|
|
14
|
-
collisions: json.collisions.map((collision) => collision.map(Cell.fromJson)),
|
|
15
19
|
points: json.points,
|
|
16
20
|
});
|
|
17
21
|
};
|
|
@@ -73,11 +77,16 @@ export class Result {
|
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
public toJson(): ResultJson {
|
|
80
|
+
const placed = this.cells.filter((cell) => cell.isEmpty);
|
|
81
|
+
|
|
76
82
|
return {
|
|
77
|
-
|
|
83
|
+
blankIndices: placed.flatMap((cell, index) => (cell.tile.isBlank ? [index] : [])),
|
|
78
84
|
id: this.id,
|
|
79
|
-
|
|
85
|
+
isHorizontal: this.isHorizontal(),
|
|
80
86
|
points: this.points,
|
|
87
|
+
tiles: placed.map((cell) => cell.tile.character),
|
|
88
|
+
x: this.cells[0].x,
|
|
89
|
+
y: this.cells[0].y,
|
|
81
90
|
};
|
|
82
91
|
}
|
|
83
92
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type CellJson } from './CellJson';
|
|
2
|
-
import { type CollisionJson } from './CollisionJson';
|
|
3
|
-
|
|
4
1
|
export interface ResultJson {
|
|
5
|
-
|
|
6
|
-
collisions: CollisionJson[];
|
|
2
|
+
blankIndices: number[];
|
|
7
3
|
id: number;
|
|
4
|
+
isHorizontal: boolean;
|
|
8
5
|
points: number;
|
|
6
|
+
tiles: string[];
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
9
|
}
|
|
@@ -8,25 +8,19 @@ export { Cell } from './Cell';
|
|
|
8
8
|
export { CellJson, isCellJson } from './CellJson';
|
|
9
9
|
export { CharacterBonus } from './CharacterBonus';
|
|
10
10
|
export { Collision } from './Collision';
|
|
11
|
-
export { CollisionJson } from './CollisionJson';
|
|
12
11
|
export { Config } from './Config';
|
|
13
12
|
export { ConfigJson } from './ConfigJson';
|
|
14
13
|
export { Dictionary } from './Dictionary';
|
|
15
|
-
export { FinalPattern } from './FinalPattern';
|
|
16
14
|
export { Game, isGame } from './Game';
|
|
17
|
-
export { HorizontalPattern } from './HorizontalPattern';
|
|
18
15
|
export { isError } from './isError';
|
|
19
16
|
export { isObject } from './isObject';
|
|
20
17
|
export { isLocale, Locale } from './Locale';
|
|
21
|
-
export { Pattern } from './Pattern';
|
|
22
|
-
export { PatternJson } from './PatternJson';
|
|
23
18
|
export { Result } from './Result';
|
|
24
19
|
export { ResultJson } from './ResultJson';
|
|
25
20
|
export { ShowCoordinates } from './ShowCoordinates';
|
|
26
21
|
export { Tile } from './Tile';
|
|
27
22
|
export { TileConfig } from './TileConfig';
|
|
28
23
|
export { isTileJson, TileJson } from './TileJson';
|
|
29
|
-
export { VerticalPattern } from './VerticalPattern';
|
|
30
24
|
export { WordBonus } from './WordBonus';
|
|
31
25
|
export { WordDefinition } from './WordDefinition';
|
|
32
26
|
export { WordDefinitionJson } from './WordDefinitionJson';
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { Board } from './Board';
|
|
4
|
+
import { Cell } from './Cell';
|
|
5
|
+
import { readCells, readCollisions } from './readResultCells';
|
|
6
|
+
import { type ResultJson } from './ResultJson';
|
|
7
|
+
import { Tile } from './Tile';
|
|
8
|
+
|
|
9
|
+
describe('readCells', () => {
|
|
10
|
+
it('reads a word placed on an empty board', () => {
|
|
11
|
+
const board = createBoard();
|
|
12
|
+
const cells = readCells(createResultJson({ tiles: ['a', 'b', 'c'], x: 1, y: 2 }), board);
|
|
13
|
+
|
|
14
|
+
expect(toWord(cells)).toBe('abc');
|
|
15
|
+
expect(toCoordinates(cells)).toBe('1,2 2,2 3,2');
|
|
16
|
+
expect(cells.every((cell) => cell.isEmpty)).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('reads a word played through existing board tiles', () => {
|
|
20
|
+
const board = createBoard([' ', ' ', ' a c ', ' ', ' ']);
|
|
21
|
+
const cells = readCells(createResultJson({ tiles: ['b'], x: 1, y: 2 }), board);
|
|
22
|
+
|
|
23
|
+
expect(toWord(cells)).toBe('abc');
|
|
24
|
+
expect(cells.map((cell) => cell.isEmpty)).toEqual([false, true, false]);
|
|
25
|
+
expect(toWord(placedCells(cells))).toBe('b');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('reads a vertical word', () => {
|
|
29
|
+
const board = createBoard([' ', ' a ', ' ', ' ', ' ']);
|
|
30
|
+
const cells = readCells(createResultJson({ isHorizontal: false, tiles: ['b', 'c'], x: 2, y: 1 }), board);
|
|
31
|
+
|
|
32
|
+
expect(toWord(cells)).toBe('abc');
|
|
33
|
+
expect(toCoordinates(cells)).toBe('2,1 2,2 2,3');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('marks placed blanks by their index among placed tiles', () => {
|
|
37
|
+
const board = createBoard([' ', ' ', ' a ', ' ', ' ']);
|
|
38
|
+
const cells = readCells(createResultJson({ blankIndices: [1], tiles: ['b', 'c'], x: 1, y: 2 }), board);
|
|
39
|
+
|
|
40
|
+
expect(toWord(cells)).toBe('abc');
|
|
41
|
+
expect(cells.map((cell) => cell.tile.isBlank)).toEqual([false, false, true]);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('stops at the board edge', () => {
|
|
45
|
+
const board = createBoard();
|
|
46
|
+
const cells = readCells(createResultJson({ tiles: ['a', 'b', 'c'], x: 3, y: 2 }), board);
|
|
47
|
+
|
|
48
|
+
expect(toWord(cells)).toBe('ab');
|
|
49
|
+
expect(toCoordinates(cells)).toBe('3,2 4,2');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('treats a candidate cell as empty', () => {
|
|
53
|
+
const board = createBoard();
|
|
54
|
+
board.updateCell(2, 2, () => new Cell({ isEmpty: true, tile: new Tile({ character: 'z' }), x: 2, y: 2 }));
|
|
55
|
+
const cells = readCells(createResultJson({ tiles: ['a', 'b', 'c'], x: 1, y: 2 }), board);
|
|
56
|
+
|
|
57
|
+
expect(toWord(cells)).toBe('abc');
|
|
58
|
+
expect(cells.every((cell) => cell.isEmpty)).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('treats a cell without a tile as empty, matching the solver', () => {
|
|
62
|
+
const board = createBoard();
|
|
63
|
+
board.updateCell(2, 2, () => new Cell({ isEmpty: false, tile: Tile.Null, x: 2, y: 2 }));
|
|
64
|
+
const cells = readCells(createResultJson({ tiles: ['a', 'b', 'c'], x: 1, y: 2 }), board);
|
|
65
|
+
|
|
66
|
+
expect(toWord(cells)).toBe('abc');
|
|
67
|
+
expect(toWord(placedCells(cells))).toBe('abc');
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe('readCollisions', () => {
|
|
72
|
+
it('reads the perpendicular word crossing a placed tile', () => {
|
|
73
|
+
const board = createBoard([' ', ' a ', ' d ', ' c ', ' ']);
|
|
74
|
+
const cells = readCells(createResultJson({ tiles: ['b'], x: 2, y: 2 }), board);
|
|
75
|
+
const collisions = readCollisions(cells, board, true);
|
|
76
|
+
|
|
77
|
+
expect(collisions.map(toWord)).toEqual(['abc']);
|
|
78
|
+
expect(toCoordinates(collisions[0])).toBe('2,1 2,2 2,3');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('reads a horizontal collision crossing a vertical word', () => {
|
|
82
|
+
const board = createBoard([' ', ' a c ', ' ', ' ', ' ']);
|
|
83
|
+
const cells = readCells(createResultJson({ isHorizontal: false, tiles: ['b', 'd'], x: 2, y: 1 }), board);
|
|
84
|
+
const collisions = readCollisions(cells, board, false);
|
|
85
|
+
|
|
86
|
+
expect(toWord(cells)).toBe('bd');
|
|
87
|
+
expect(collisions.map(toWord)).toEqual(['abc']);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('reads one collision per placed tile', () => {
|
|
91
|
+
const board = createBoard([' a a', ' ', ' ', ' ', ' ']);
|
|
92
|
+
const cells = readCells(createResultJson({ tiles: ['b', 'c', 'b'], x: 2, y: 1 }), board);
|
|
93
|
+
|
|
94
|
+
expect(readCollisions(cells, board, true).map(toWord)).toEqual(['ab', 'ab']);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('ignores placed tiles without a perpendicular neighbour', () => {
|
|
98
|
+
const board = createBoard();
|
|
99
|
+
const cells = readCells(createResultJson({ tiles: ['a', 'b'], x: 1, y: 2 }), board);
|
|
100
|
+
|
|
101
|
+
expect(readCollisions(cells, board, true)).toEqual([]);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('does not cross a candidate cell', () => {
|
|
105
|
+
const board = createBoard();
|
|
106
|
+
board.updateCell(2, 1, () => new Cell({ isEmpty: true, tile: new Tile({ character: 'z' }), x: 2, y: 1 }));
|
|
107
|
+
const cells = readCells(createResultJson({ tiles: ['a', 'b', 'c'], x: 1, y: 2 }), board);
|
|
108
|
+
|
|
109
|
+
expect(readCollisions(cells, board, true)).toEqual([]);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
function createBoard(rows: string[] = [' ', ' ', ' ', ' ', ' ']): Board {
|
|
114
|
+
return Board.fromStringArray(rows);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function createResultJson(json: Partial<ResultJson> = {}): ResultJson {
|
|
118
|
+
return {
|
|
119
|
+
blankIndices: [],
|
|
120
|
+
id: 0,
|
|
121
|
+
isHorizontal: true,
|
|
122
|
+
points: 0,
|
|
123
|
+
tiles: [],
|
|
124
|
+
x: 0,
|
|
125
|
+
y: 0,
|
|
126
|
+
...json,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function placedCells(cells: Cell[]): Cell[] {
|
|
131
|
+
return cells.filter((cell) => cell.isEmpty);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function toWord(cells: Cell[]): string {
|
|
135
|
+
return cells.map(String).join('');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function toCoordinates(cells: Cell[]): string {
|
|
139
|
+
return cells.map(({ x, y }) => `${x},${y}`).join(' ');
|
|
140
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type Board } from './Board';
|
|
2
|
+
import { Cell } from './Cell';
|
|
3
|
+
import { type ResultJson } from './ResultJson';
|
|
4
|
+
import { Tile } from './Tile';
|
|
5
|
+
|
|
6
|
+
export function readCells(json: ResultJson, board: Board): Cell[] {
|
|
7
|
+
const stepX = json.isHorizontal ? 1 : 0;
|
|
8
|
+
const stepY = json.isHorizontal ? 0 : 1;
|
|
9
|
+
const cells: Cell[] = [];
|
|
10
|
+
let placedIndex = 0;
|
|
11
|
+
let { x, y } = json;
|
|
12
|
+
|
|
13
|
+
while (y < board.rowsCount && x < board.columnsCount) {
|
|
14
|
+
const boardCell = board.rows[y][x];
|
|
15
|
+
|
|
16
|
+
if (boardCell.isFilled()) {
|
|
17
|
+
cells.push(boardCell.clone());
|
|
18
|
+
} else if (placedIndex < json.tiles.length) {
|
|
19
|
+
cells.push(readPlacedCell(json, placedIndex, x, y));
|
|
20
|
+
placedIndex += 1;
|
|
21
|
+
} else {
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
x += stepX;
|
|
26
|
+
y += stepY;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return cells;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function readCollisions(cells: Cell[], board: Board, isHorizontal: boolean): Cell[][] {
|
|
33
|
+
const collisions: Cell[][] = [];
|
|
34
|
+
|
|
35
|
+
for (const cell of cells) {
|
|
36
|
+
if (cell.isFilled()) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const collision = readCollision(cell, board, isHorizontal);
|
|
41
|
+
|
|
42
|
+
if (collision.length > 1) {
|
|
43
|
+
collisions.push(collision);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return collisions;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function readPlacedCell(json: ResultJson, placedIndex: number, x: number, y: number): Cell {
|
|
51
|
+
const character = json.tiles[placedIndex];
|
|
52
|
+
const isBlank = json.blankIndices.includes(placedIndex);
|
|
53
|
+
return new Cell({ isEmpty: true, tile: new Tile({ character, isBlank }), x, y });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function readCollision(placed: Cell, board: Board, isHorizontal: boolean): Cell[] {
|
|
57
|
+
const stepX = isHorizontal ? 0 : 1;
|
|
58
|
+
const stepY = isHorizontal ? 1 : 0;
|
|
59
|
+
let x = placed.x - stepX;
|
|
60
|
+
let y = placed.y - stepY;
|
|
61
|
+
|
|
62
|
+
while (x >= 0 && y >= 0 && board.rows[y][x].isFilled()) {
|
|
63
|
+
x -= stepX;
|
|
64
|
+
y -= stepY;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
x += stepX;
|
|
68
|
+
y += stepY;
|
|
69
|
+
|
|
70
|
+
const collision: Cell[] = [];
|
|
71
|
+
|
|
72
|
+
while (y < board.rowsCount && x < board.columnsCount) {
|
|
73
|
+
if (x === placed.x && y === placed.y) {
|
|
74
|
+
collision.push(placed);
|
|
75
|
+
} else {
|
|
76
|
+
const boardCell = board.rows[y][x];
|
|
77
|
+
|
|
78
|
+
if (!boardCell.isFilled()) {
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
collision.push(boardCell.clone());
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
x += stepX;
|
|
86
|
+
y += stepY;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return collision;
|
|
90
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrabble-solver/word-definitions",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"description": "Scrabble Solver 2 - Word definitions",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
},
|
|
20
20
|
"homepage": "https://scrabble-solver.org",
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "
|
|
22
|
+
"build": "tsc --project .",
|
|
23
23
|
"clean": "rimraf build/",
|
|
24
24
|
"test": "bun test --timeout 180000 src"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@scrabble-solver/types": "^2.
|
|
27
|
+
"@scrabble-solver/types": "^2.17.0",
|
|
28
28
|
"cheerio": "^1.2.0",
|
|
29
29
|
"follow-redirects": "^1.16.0",
|
|
30
30
|
"striptags": "^3.2.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrabble-solver/word-lists",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"description": "Scrabble Solver 2 - Word lists",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
},
|
|
20
20
|
"homepage": "https://scrabble-solver.org",
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "
|
|
22
|
+
"build": "tsc --project .",
|
|
23
23
|
"clean": "rimraf build/"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@scrabble-solver/types": "^2.
|
|
26
|
+
"@scrabble-solver/types": "^2.17.0",
|
|
27
27
|
"cheerio": "^1.2.0",
|
|
28
28
|
"follow-redirects": "^1.16.0",
|
|
29
29
|
"transliteration": "^2.6.1",
|
|
30
|
-
"unzipper": "^0.12.
|
|
30
|
+
"unzipper": "^0.12.5"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/follow-redirects": "^1.14.4",
|