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