Implementation of Wordle game engine with JavaScript.
pnpm add @socnik/wordle-engine # Pnpm
npm install @socnik/wordle-engine # Npm
Core type of this library - LetterGuessingState
. It represents color of tile in Wordle game.
- none - white
- almost - yellow
- right - green
- wrong - gray
type LetterGuessingState = 'none' | 'almost' | 'right' | 'wrong'
Allows create Wordle game board state.
Create new board with specified size. Board state - 2D matrix with tile state objects. Tile state have two properties:
letter
- tile letterguessingState
- one value fromLetterGuessingState
type.
type BoardTileState = {
letter: string
guessingState: LetterGuessingState
}
Compare words with Wordle game rules and return array with result. Every array item has one of this values:
'almost' | 'right' | 'wrong'
.
diffWords('abcd', 'dbcf')
// Result: ['wrong', 'right', 'right', 'almost']
More docs come soon...