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

Reference · Marking, scores and game rules

WordGameSubmittype

A guess sent in: the round after it, and why the guess was not taken, if it was not.

Import it

import type { WordGameSubmit } from "@johnmorrisdotca/kotoba";

Definition

type WordGameSubmit = {
    game: WordGame;
    refused: WordGameRefusal | null;
};

Members

NameTypeDescription
gameWordGame
refusedWordGameRefusal | null

Examples

import { readWordLists, startWordGame, submitWordGame, typeWordGame } from "@johnmorrisdotca/kotoba";
import { EN_WORDS } from "@johnmorrisdotca/kotoba/words-en";
import type { WordGameSubmit } from "@johnmorrisdotca/kotoba";

const wordLists = readWordLists(EN_WORDS,5)!;
const game = startWordGame("en",5,"apple");
const typed = [..."apple"].reduce((state,key)=>typeWordGame(state,key,1000),game);
const submitted = submitWordGame(typed,wordLists,20000);
const value: WordGameSubmit = submitted;
console.log(value);
{
  game: {
    language: 'en',
    size: 5,
    rows: 6,
    hidden: 'apple',
    guesses: [ 'apple' ],
    typed: [],
    pending: '',
    status: 'won',
    startedAt: 1000,
    score: { placed: 300, elsewhere: 0, found: 425, speed: 50, total: 775 }
  },
  refused: null
}

What it prints (run when this page was built)

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