Skip to the content

Kotoba言葉

Load only the word lists you need, mark repeated letters correctly and play a daily or seeded word game.

Kotoba is the Japanese word for words. About the name

Contents

How-to

Mark guesses and score a round

Handle repeated letters before awarding place and speed points.

Repeated letters consume a count

import {markGuess,wordScore} from "@johnmorrisdotca/kotoba";
console.log(markGuess("alley","apple"));
console.log(wordScore("apple",["alley","apple"],6,20000));
[ 'hit', 'near', 'miss', 'near', 'miss' ]
{ placed: 260, elsewhere: 0, found: 400, speed: 50, total: 710 }

Exact positions are marked first. Remaining hidden-letter counts are consumed left to right for elsewhere matches, so a repeated guess letter cannot claim more matches than the answer contains. Pure marking expects the native same-length form; use decodeHidden/decodeGuesses or the game submission layer when validating external input.

Native scoring

Placed and elsewhere letters earn points when first discovered, weighted by the guesses remaining. Finding the word adds a bonus and unused-row points; speed points apply only to a found word. Supply elapsed milliseconds and configured row count, not a new clock read for every reconstruction. A lost round can still score letter discoveries. submitWordGame rejects a short or unlisted guess and returns both state and refusal; it does not charge a row for a refused word. See wordScore and game submission.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/kotoba 1.2.0.