UNPKG

scrabble-solver

Version:

Scrabble Solver 2 - Free, open-source, cross-platform, multi-language analysis tool for Scrabble, Scrabble Duel, Super Scrabble, Letter League, Crossplay, Literaki, and Kelimelik. Quickly find the top-scoring words using the given board and tiles.

28 lines (22 loc) 865 B
import { createSelector } from '@reduxjs/toolkit'; import { findCell } from '@/lib'; import { selectBoard, selectCharacters, selectConfig, selectHighlightUnreachableCells, selectResultCandidateCells, } from '@/state'; import { getReachableCells } from './lib'; export const selectRowsWithCandidate = createSelector([selectBoard, selectResultCandidateCells], (board, cells) => { return board.rows.map((row, y) => row.map((cell, x) => findCell(cells, x, y) || cell)); }); export const selectReachableCells = createSelector( [selectConfig, selectBoard, selectCharacters, selectHighlightUnreachableCells], (config, board, characters, highlightUnreachableCells): boolean[][] | null => { if (!highlightUnreachableCells || characters.length === 0) { return null; } return getReachableCells(config, board, characters.length); }, );