0.0.2 • Published 19 days ago

@socnik/wordle-engine v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
19 days ago

Wordle Engine

Implementation of Wordle game engine with JavaScript.

Installation

pnpm add @socnik/wordle-engine # Pnpm
npm install @socnik/wordle-engine # Npm

Docs

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 letter
  • guessingState - one value from LetterGuessingState type.
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...

0.0.2

19 days ago

0.0.1

19 days ago

0.0.0

19 days ago