diff --git a/README.md b/README.md index c8d6470..13ebcc5 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ An app runs on a watch with the patched firmware and the App Loader, both on the | [`trip-computer`](apps/trip-computer) | A GPS speedometer and trip computer on the watch's own GPS: speed, distance, moving time, average, top speed and ascent; a page next to the face and a widget card | | [`connect-four`](apps/connect-four) | Connect Four against a negamax bot on three levels: tap a column to drop a disc | | [`tech-news`](apps/tech-news) | The Hacker News front page: top headlines with points, comments and age, a page next to the face and a widget card (needs FMC Companion) | +| [`word-guess`](apps/word-guess) | Guess the hidden five-letter word in six tries: a daily word, unlimited practice and statistics | ## Make your own app diff --git a/apps/word-guess/Cargo.toml b/apps/word-guess/Cargo.toml new file mode 100644 index 0000000..a5f7d68 --- /dev/null +++ b/apps/word-guess/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "word-guess" +edition.workspace = true +license.workspace = true +version.workspace = true + +[dependencies] +cmf-wp2-app.workspace = true +cmf-wp2-ui.workspace = true + +[[bin]] +name = "word-guess" +bench = false diff --git a/apps/word-guess/WORDS.md b/apps/word-guess/WORDS.md new file mode 100644 index 0000000..37f6072 --- /dev/null +++ b/apps/word-guess/WORDS.md @@ -0,0 +1,40 @@ +# Word Guess: word lists + +Both lists are made by [`tools/gen_words.py`](tools/gen_words.py) from two public-domain sources, and the build packs +them into the app (`src/words.rs`): each word as five 5-bit letters in a `u32`, 8,636 × 4 B for the guesses and +1,890 × 2 B (indices into the guesses) for the answers, about 38 KiB of the 128 KiB image. + +| File | Words | What it is | +|---|---|---| +| [`data/guesses.txt`](data/guesses.txt) | 8,636 | every word you may type, sorted | +| [`data/answers.txt`](data/answers.txt) | 1,890 | the hidden words, in the order the daily word walks through | + +## Sources + +**ENABLE** (Enhanced North American Benchmark LExicon, `enable1.txt`), public domain. Used for the guesses: every +five-letter word in it. Taken from , sha256 +`3f16130220645692ed49c7134e24a18504c2ca55b3c012f7290e3e77c63b1a89`. + +**12dicts** 6.0.2 by Alan Beale, public domain; the author asks that its use be acknowledged, which this is. Used for +the answers: `Lemmatized/2+2+3frq.txt`, the head words of the lemmatized common-word list ranked in frequency +classes. From , see . + +## How the answers are chosen + +1. Head words (lemmas: no plural or past-tense forms) of `2+2+3frq.txt` in frequency classes 1 to 16, the most common + words in English. +2. Five lowercase letters a-z only, so no proper nouns, abbreviations or hyphens; and in ENABLE too. +3. Words ending in "s" whose first four letters are a word themselves ("jeans", "blues") are left out as plural-looking. +4. A blocklist in the script drops offensive, crude and upsetting words. +5. The rest is shuffled once with a fixed seed (splitmix64 and Fisher-Yates, written out in the script, so it is the + same on every machine). The daily word for local date D is `answers[(days from 2026-12-01 to D) mod 1890]`, so it + repeats only after about five years. + +## Making them again + +```bash +python apps/word-guess/tools/gen_words.py --enable enable1.txt --frq 12dicts/Lemmatized/2+2+3frq.txt +``` + +Any change to either list changes the daily words from then on: raise the app's version. A daily game saved with a +word that is no longer that day's is dropped when the app loads. diff --git a/apps/word-guess/data/answers.txt b/apps/word-guess/data/answers.txt new file mode 100644 index 0000000..5975ab3 --- /dev/null +++ b/apps/word-guess/data/answers.txt @@ -0,0 +1,1890 @@ +crave +unite +rainy +money +alibi +groin +naked +flash +nutty +fauna +dream +woman +gripe +savor +bloke +relay +flick +bossy +court +testy +psalm +fresh +budge +mourn +karma +broth +bible +frill +unmet +arrow +husky +china +prowl +child +crisp +bumpy +ranch +crawl +agree +diode +clasp +coach +azure +stack +carat +swamp +forum +fella +mocha +whirl +serve +gooey +rotor +stool +mover +maxim +seedy +avoid +booze +slush +fruit +heist +fifth +mummy +swing +yacht +chant +title +amaze +trail +plant +fetch +epoch +murky +tasty +prank +wagon +furor +colon +lofty +purse +valor +berry +point +sleet +scare +burst +theme +draft +quest +begin +patio +bleed +piano +award +slime +carer +droop +setup +dwell +khaki +maize +slang +faint +tenet +cruel +shave +empty +navel +salsa +mirth +thyme +rifle +breed +sight +bunch +tread +shunt +twist +pizza +cower +gauze +trait +offer +marry +skier +medal +angry +bride +every +chair +salad +adult +would +dwarf +total +feign +bulky +quilt +phone +yearn +drink +array +queen +cycle +shrub +fable +weave +allow +flock +shark +grimy +paste +flare +shank +modem +beget +balmy +gauge +genus +dodge +stead +pilot +relic +civic +snail +steal +vodka +rouge +condo +raspy +motor +bison +quake +rigor +needy +femur +index +goofy +guild +moist +derby +ought +latex +chase +panic +lease +flute +ahold +virus +hotel +plume +lodge +amble +tacky +heave +skate +sheet +medic +scorn +imply +stall +witch +bacon +swirl +brute +whack +exert +louse +drape +smart +spire +jelly +argue +purge +feast +gouge +saver +thick +glory +cabby +horde +organ +tense +tangy +abode +crime +munch +scant +tenor +wrath +spiky +pudgy +bravo +steak +merit +flail +mafia +churn +craze +album +evict +youth +whole +blank +roomy +jaunt +sidle +click +speed +abhor +waist +dusky +shoot +clink +reply +sneak +whine +mason +ruddy +frown +stilt +pique +width +dozen +caulk +hater +creak +liter +plush +riser +swear +alive +gloom +eater +thank +morph +decaf +lunge +share +laden +amuse +exude +ideal +meaty +quack +stick +baker +right +debit +smash +heady +graph +phase +niche +sandy +gorge +undue +fjord +green +issue +valve +molar +clout +digit +pound +dense +joint +baggy +grasp +cocoa +panda +clown +atlas +inter +cameo +guest +flesh +birth +agony +trick +fudge +limbo +snuff +piety +shack +posit +skiff +rebut +cedar +tempt +stock +brine +aegis +maple +ready +enjoy +knife +topic +viper +spine +lupus +brush +abbey +strew +bleep +track +racer +upper +swoop +prune +small +dizzy +avert +rigid +forte +carve +belie +botch +dryer +seize +proof +aspen +fleet +overt +probe +axiom +pulse +brick +heron +pacer +blend +homey +flame +sauce +brave +inlay +loose +drool +pleat +frank +emery +heavy +brink +canoe +super +pride +cider +suede +beard +belle +tonal +daily +drift +lyric +strap +towel +havoc +basis +gourd +inset +elite +major +meter +creed +crier +banjo +trawl +imbue +ratty +aback +while +sheaf +hound +tempo +bland +dogma +bagel +spade +pivot +mercy +dingy +round +guilt +press +asset +cream +soapy +vigor +peony +cheer +class +harem +nudge +moody +quell +scrap +bring +oldie +rider +usual +crude +cargo +winch +clerk +could +growl +squat +sauna +field +cleft +curry +torch +prime +giver +habit +hobby +great +enact +voice +thump +weigh +coupe +evoke +abbot +final +sully +prawn +amass +label +adage +fleck +lorry +steel +knock +brief +elder +among +befit +grape +score +parka +audit +midst +hunch +gloss +refer +prism +recur +unity +penny +lumpy +utter +milky +onion +shame +noble +scuff +groom +cheat +chimp +steep +bough +rabbi +chard +adobe +otter +slink +tutor +comic +fetal +lapse +visor +bathe +sleep +combo +sonic +topaz +bloom +house +piece +sushi +glint +group +fiber +chain +bugle +afoot +frond +clash +sweat +ghoul +ethos +stalk +cover +blunt +aloud +spike +smile +mound +break +grass +bingo +quiet +grunt +devil +mania +ferry +bowel +curly +earth +sieve +situp +alter +levee +corps +quota +grind +staff +dirty +padre +slide +stash +papal +wader +spare +toxic +crowd +furry +snipe +batch +druid +build +razor +shall +jolly +alarm +kayak +groan +judge +slack +rinse +tiger +diner +quite +flunk +melon +pecan +rusty +serum +jetty +react +niece +movie +truce +cloak +rater +trace +smock +hence +verge +voter +paddy +chart +toxin +liver +exalt +visit +tress +worry +trope +elbow +radon +photo +pause +rough +hefty +beech +queue +power +qualm +tenth +aware +stone +civil +await +delta +spate +moldy +match +haunt +fluff +singe +ember +potty +chemo +rogue +plain +shirt +slick +model +turbo +trove +vivid +swede +vegan +boast +knack +order +rodeo +pinch +drone +irate +tulip +stoic +front +metro +nymph +troop +hatch +ocher +tinge +vicar +slant +enter +scrub +salon +glass +cramp +chest +haven +equal +haste +beige +gamma +plate +stink +polka +taunt +tower +naval +cocky +cause +stony +caper +plaid +realm +flour +foray +bogey +quirk +smack +swift +abide +slump +macho +wharf +pearl +basal +madam +clank +cleat +opera +baron +patty +rebel +sonar +whoop +abort +debut +swell +weird +tipsy +river +payer +shuck +glove +decoy +novel +crony +brake +quart +grave +steer +strut +nasal +spoof +hover +nexus +silky +barge +hoard +solve +coral +champ +birch +dairy +assay +quill +abate +chide +conch +felon +horse +buggy +count +tonic +wheat +snowy +legal +swipe +trout +blush +sassy +bogus +train +rally +flora +mower +coast +scene +chive +spill +tango +canon +plumb +raise +sinus +shine +grace +crash +ocean +frame +limit +short +snout +usher +glean +acrid +cumin +elate +venom +mater +glaze +inert +flair +scuba +fairy +tramp +frock +close +plank +blink +cadre +kappa +march +fishy +naive +optic +grail +posse +stout +itchy +ethic +uncle +excel +duchy +actor +spoil +clack +sweet +outdo +ovary +water +hilly +eerie +adore +endow +audio +oasis +wheel +shale +shrew +which +vault +dolly +avail +seven +party +sheep +hyena +grime +agent +spool +viola +brook +ensue +dusty +foggy +prong +scalp +urban +graft +beast +runny +upset +angle +brass +shake +enemy +hello +lousy +mayor +psych +clamp +stump +query +totem +faith +charm +depot +spurt +slope +mince +adorn +erect +brawl +allay +pagan +yummy +guile +apple +vapor +squad +black +still +sigma +crumb +trump +bribe +snare +aroma +axial +ruble +loser +sharp +cease +taste +sixth +adapt +bosom +taboo +kiddo +girth +human +pasta +gleam +fuzzy +theft +hinge +raven +bread +awash +adept +throw +juice +beach +crank +stint +peach +alias +perky +bushy +sober +duvet +wiper +twice +tunic +screw +fraud +rupee +blaze +sunny +crypt +widow +cloud +muddy +liken +upend +peace +cable +glide +loner +delay +night +stove +spell +skirt +nurse +flaky +valid +witty +twine +boxer +below +chess +spook +scion +study +alloy +chewy +spurn +forgo +agile +sewer +grill +tweed +trunk +waver +blurt +young +ample +lance +patch +peril +demon +silly +attic +clone +there +broom +spicy +spark +quark +crest +spend +polyp +wield +block +cloth +wrist +beefy +sound +slate +rivet +genie +stoop +fancy +acorn +mimic +unfit +mogul +inlet +scone +smell +alike +unwed +local +camel +gloat +waltz +jumpy +cynic +after +couch +delve +flake +lurch +smelt +pious +shawl +speak +douse +clean +parch +newly +linen +irony +favor +shaky +wrest +shell +style +alien +slosh +lefty +altar +llama +beret +hasty +talon +nasty +unlit +think +bluff +brain +blitz +swine +world +notch +stark +acute +lemon +wager +motif +tough +boost +float +erode +sonny +waive +sixty +flank +poach +hubby +gator +scoop +clump +shush +drama +rerun +easel +choir +anger +swath +viral +flush +shape +infer +scale +scald +goody +drawl +hyper +shock +yield +nerve +sedan +state +ninth +leery +strum +gnarl +happy +lurid +heart +cheap +trial +rival +royal +saber +dummy +laugh +force +peter +golly +edict +wrong +jerky +sloth +shire +buyer +mossy +teach +polar +armor +filet +annul +thumb +baste +panel +robin +tidal +wince +above +cigar +spear +lotus +oxide +avian +alert +south +forge +privy +sheen +slurp +pixel +leech +stale +snort +again +shear +eagle +eject +widen +slimy +affix +robot +syrup +truck +mouth +noose +mulch +sling +fight +brace +gamut +salty +burly +beset +grain +cello +taper +dance +bless +radio +caste +stamp +crane +chuck +cubic +parse +input +broad +slash +focal +vital +blame +peeve +creme +depth +stoke +teeny +minus +locus +staid +eager +alpha +jumbo +denim +facet +harsh +chime +forth +belch +saute +poker +cliff +canny +siren +drake +weary +alder +shout +manor +amber +lipid +latch +plait +leash +fifty +booth +maker +claim +laser +theta +weedy +elect +embed +nifty +circa +board +scoot +gland +taker +pitch +folly +plunk +error +pesto +grade +decor +comet +stage +shiny +aisle +basic +bloat +leach +watch +amiss +lunch +gizmo +soggy +ditch +recap +gross +helix +occur +ether +abyss +blade +tawny +nylon +demur +bench +angst +crepe +trend +epoxy +hairy +giant +tardy +cheek +color +lunar +splay +alone +curve +stain +scout +spray +ounce +chill +incur +retro +fetus +paper +scarf +cabin +basil +crack +orbit +rocky +biker +micro +hardy +learn +shrug +drain +whisk +harry +tooth +thorn +their +usage +livid +snoop +gusto +never +revel +alley +palsy +drive +mount +quick +canal +inept +angel +roast +ruler +maybe +hedge +snack +stave +fluke +broil +gruff +suave +leave +apron +quail +funny +pixie +shove +focus +sorry +leaky +smoke +timer +macro +timid +spout +handy +vague +ridge +erase +renew +elope +promo +vista +creep +wreak +triad +mommy +minor +radar +lucid +antic +spore +table +aphid +wacky +throe +honey +spasm +renal +often +lover +matte +plump +baton +union +shred +sheer +crass +whose +rugby +comfy +vowel +merge +stomp +joker +tribe +sword +thing +tweak +exile +hurry +dread +decry +merry +ripen +wring +ghost +flood +false +venue +flask +humor +atone +aloft +intro +cushy +donor +resin +prize +evade +lager +brood +porch +piper +crock +truss +troll +hiker +throb +omega +aloof +blood +farce +pager +awful +titan +gumbo +binge +death +pluck +braid +kitty +apart +mushy +trust +perch +froth +greet +since +reuse +juicy +spank +graze +gable +space +rowdy +rapid +cross +snarl +stand +covet +mauve +solar +trash +chalk +onset +early +berth +grand +cadet +algal +brand +chili +carry +logic +nanny +choke +plead +chaos +noisy +impel +blast +ankle +doggy +sport +forty +tally +belly +cache +dress +guide +until +jewel +tumor +diver +vocal +hoist +corny +nomad +badge +crate +other +piggy +rover +worth +route +aside +solid +opium +level +globe +miner +stair +modal +fence +motto +thief +tepee +aural +pesky +prove +large +doubt +homer +smirk +decay +petty +prone +leafy +indie +diary +video +chasm +outer +elude +spoon +light +tweet +cobra +foyer +frail +pupil +lucky +ulcer +ahead +loyal +scent +extol +pansy +straw +howdy +dowry +mucus +savvy +regal +arena +surly +mouse +knoll +brunt +shore +ebony +crimp +repay +rhino +extra +blind +legit +polio +store +spree +drill +frost +lanky +where +check +bobby +tacit +fling +third +cinch +scary +larva +torso +today +annex +prose +comer +shaft +celeb +guess +whale +roost +wedge +freak +adopt +disco +suite +smear +juror +squid +bully +spice +deity +rural +marsh +knead +spawn +dicey +place +filth +verse +fatal +remit +wafer +flier +media +chute +admit +kiosk +gutsy +paint +liner +three +equip +abuse +junta +punch +unzip +taint +fiver +segue +askew +stuff +amend +giddy +clang +saint +ninja +quote +wispy +skunk +daunt +puffy +anvil +price +guard +brash +telly +putty +chord +humid +puppy +greed +butte +pushy +credo +risky +lobby +loath +chick +cater +siege +penal +satin +sense +rumor +eight +swish +waste +chafe +strip +croak +entry +guise +puree +prior +image +algae +ozone +curse +bulge +under +story +halve +defer +grief +stunt +daisy +terse +motel +relax +pedal +owner +phony +chirp +shift +clear +snake +steam +magic +snore +scowl +tuber +sweep +whiff +spite +bleat +basin +rehab +chomp +vouch +untie +twirl +villa +picky +vogue +blond +awake +carol +dandy +scold +sheik +crush +rhyme +synod +mango +erupt +twang +music +tepid +icing +catch +edema +cough +treat +lithe +lymph +sneer +slice +flout +filly +crown +joist +buddy +sting +arson +preen +idiom +surge +event +grate +creek +shard +comma +fault +thong +bayou +poppy +folio +scope +daddy +hitch +flint +drown +fiend +along +bliss +exist +metal +expel +ratio +tummy +sprig +zebra +windy +truth +stray +vigil +thigh +holly +plane +layup +libel +tight +musty +fussy +sniff +vinyl +deter +gavel +friar +goose +stare +rabid +essay +print +exact +dough +toast +flirt +smoky +stern +annoy +speck +reign +craft +usurp +reach +sleek +clock +moral +first +chunk +messy +latte +sever +lingo +fluid +storm +token +repel +showy +cluck +pouch +white +sugar +bonus +gravy +lilac +touch +lever +magma +might +gaudy +unify +floss +skill +grant +croon +valet +write +ledge +shady +blare +mural +value +proxy +smite +stiff +poise +cling +plaza +clove +shade +laity +split +banal +bunny +honor +wreck +gaffe +kneel +apply +fiery +gaunt +grove +proud +arise +brown +allot +glade +genre +brisk +start +scour +glare +skull +crazy +rouse +north +olive +labor +yeast +climb +crook +about +month +quash +lapel +range +funky +ivory +candy +tease +mixer +chore +inner +chief +petal +shelf +tract +manic +align +floor +misty +ultra +reset +feral +envoy +fever +bleak +ladle +trade +noise +swarm +opine +scoff +crust +stake +swoon +layer diff --git a/apps/word-guess/data/guesses.txt b/apps/word-guess/data/guesses.txt new file mode 100644 index 0000000..b31773b --- /dev/null +++ b/apps/word-guess/data/guesses.txt @@ -0,0 +1,8636 @@ +aahed +aalii +aargh +abaca +abaci +aback +abaft +abaka +abamp +abase +abash +abate +abbas +abbes +abbey +abbot +abeam +abele +abets +abhor +abide +abler +ables +abmho +abode +abohm +aboil +aboma +aboon +abort +about +above +abris +abuse +abuts +abuzz +abyes +abysm +abyss +acari +acerb +aceta +ached +aches +achoo +acids +acidy +acing +acini +ackee +acmes +acmic +acned +acnes +acock +acold +acorn +acred +acres +acrid +acted +actin +actor +acute +acyls +adage +adapt +addax +added +adder +addle +adeem +adept +adieu +adios +adits +adman +admen +admit +admix +adobe +adobo +adopt +adore +adorn +adown +adoze +adult +adunc +adust +adyta +adzes +aecia +aedes +aegis +aeons +aerie +afars +affix +afire +afoot +afore +afoul +afrit +after +again +agama +agape +agars +agate +agave +agaze +agene +agent +agers +agger +aggie +aggro +aghas +agile +aging +agios +agism +agist +aglee +aglet +agley +aglow +agmas +agone +agons +agony +agora +agree +agria +agues +ahead +ahold +ahull +aided +aider +aides +ailed +aimed +aimer +aioli +aired +airer +airns +airth +airts +aisle +aitch +aiver +ajiva +ajuga +akees +akela +akene +alack +alamo +aland +alane +alang +alans +alant +alarm +alary +alate +albas +album +alcid +alder +aldol +alecs +alefs +aleph +alert +alfas +algae +algal +algas +algid +algin +algor +algum +alias +alibi +alien +alifs +align +alike +aline +alist +alive +aliya +alkyd +alkyl +allay +allee +alley +allod +allot +allow +alloy +allyl +almah +almas +almeh +almes +almud +almug +aloes +aloft +aloha +aloin +alone +along +aloof +aloud +alpha +altar +alter +altho +altos +alula +alums +alway +amahs +amain +amass +amaze +amber +ambit +amble +ambos +ambry +ameba +ameer +amend +amens +ament +amias +amice +amici +amide +amido +amids +amies +amiga +amigo +amine +amino +amins +amirs +amiss +amity +ammos +amnia +amnic +amoks +amole +among +amort +amour +ample +amply +ampul +amuck +amuse +amyls +ancon +anear +anele +anent +angas +angel +anger +angle +angry +angst +anile +anils +anima +anime +animi +anion +anise +ankhs +ankle +ankus +anlas +annal +annas +annex +annoy +annul +anoas +anode +anole +anomy +ansae +antae +antas +anted +antes +antic +antis +antra +antre +antsy +anvil +aorta +apace +apart +apeak +apeek +apers +apery +aphid +aphis +apian +aping +apish +apnea +apods +aport +appal +appel +apple +apply +apres +apron +apses +apsis +apter +aptly +aquae +aquas +araks +arbor +arced +arcus +ardeb +ardor +areae +areal +areas +areca +areic +arena +arete +argal +argil +argle +argol +argon +argot +argue +argus +arhat +arias +ariel +arils +arise +arles +armed +armer +armet +armor +aroid +aroma +arose +arpen +arras +array +arris +arrow +arses +arsis +arson +artal +artel +artsy +arums +arval +arvos +aryls +asana +ascot +ascus +asdic +ashed +ashen +ashes +aside +asked +asker +askew +askoi +askos +aspen +asper +aspic +aspis +assai +assay +asses +asset +aster +astir +asyla +ataps +ataxy +atilt +atlas +atman +atmas +atoll +atoms +atomy +atone +atony +atopy +atria +atrip +attar +attic +audad +audio +audit +auger +aught +augur +aulic +aunts +aunty +aurae +aural +aurar +auras +aurei +aures +auric +auris +aurum +autos +auxin +avail +avant +avast +avens +avers +avert +avgas +avian +avion +aviso +avoid +avows +await +awake +award +aware +awash +awful +awing +awned +awoke +awols +axels +axial +axile +axils +axing +axiom +axion +axite +axled +axles +axman +axmen +axone +axons +ayahs +ayins +azans +azide +azido +azine +azlon +azoic +azole +azons +azote +azoth +azure +baaed +baals +babas +babel +babes +babka +baboo +babul +babus +bacca +backs +bacon +baddy +badge +badly +baffs +baffy +bagel +baggy +bahts +bails +bairn +baith +baits +baiza +baize +baked +baker +bakes +balas +balds +baldy +baled +baler +bales +balks +balky +balls +bally +balms +balmy +balsa +banal +banco +bands +bandy +baned +banes +bangs +banjo +banks +banns +banty +barbe +barbs +barde +bards +bared +barer +bares +barfs +barge +baric +barks +barky +barms +barmy +barns +barny +baron +barre +barye +basal +based +baser +bases +basic +basil +basin +basis +basks +bassi +basso +bassy +baste +basts +batch +bated +bates +bathe +baths +batik +baton +batts +battu +batty +bauds +baulk +bawds +bawdy +bawls +bawty +bayed +bayou +bazar +bazoo +beach +beads +beady +beaks +beaky +beams +beamy +beano +beans +beard +bears +beast +beats +beaus +beaut +beaux +bebop +becap +becks +bedel +bedew +bedim +beech +beefs +beefy +beeps +beers +beery +beets +befit +befog +began +begat +beget +begin +begot +begum +begun +beige +beigy +being +belay +belch +belga +belie +belle +bells +belly +below +belts +bemas +bemix +bench +bends +bendy +benes +benne +benni +benny +bents +beret +bergs +berme +berms +berry +berth +beryl +beset +besom +besot +bests +betas +betel +beths +beton +betta +bevel +bevor +bewig +bezel +bezil +bhang +bhoot +bhuts +biali +bialy +bibbs +bible +bices +biddy +bided +bider +bides +bidet +bield +biers +biffs +biffy +bifid +bight +bigly +bigot +bijou +biked +biker +bikes +bikie +bilbo +biles +bilge +bilgy +bilks +bills +billy +bimah +bimas +bimbo +binal +bindi +binds +bines +binge +bingo +binit +bints +biome +biont +biota +biped +bipod +birch +birds +birks +birle +birls +birrs +birse +birth +bises +bisks +bison +bitch +biter +bites +bitsy +bitts +bitty +bizes +blabs +black +blade +blahs +blain +blame +blams +bland +blank +blare +blase +blast +blate +blats +blawn +blaws +blaze +bleak +blear +bleat +blebs +bleed +bleep +blend +blent +bless +blest +blets +blimp +blimy +blind +blini +blink +blips +bliss +blite +blitz +bloat +blobs +block +blocs +bloke +blond +blood +bloom +bloop +blots +blown +blows +blowy +blubs +blued +bluer +blues +bluet +bluey +bluff +blume +blunt +blurb +blurs +blurt +blush +blype +board +boars +boart +boast +boats +bobby +bocce +bocci +boche +bocks +boded +bodes +boffo +boffs +bogan +bogey +boggy +bogie +bogle +bogus +bohea +boils +boing +boite +bolar +bolas +bolds +boles +bolls +bolos +bolts +bolus +bombe +bombs +bonds +boned +boner +bones +boney +bongo +bongs +bonks +bonne +bonny +bonus +bonze +boobs +booby +booed +boogy +books +booms +boomy +boons +boors +boost +booth +boots +booty +booze +boozy +boral +boras +borax +bored +borer +bores +boric +borne +boron +borts +borty +bortz +bosks +bosky +bosom +boson +bossy +bosun +botas +botch +botel +bothy +botts +bough +boule +bound +bourg +bourn +bouse +bousy +bouts +bovid +bowed +bowel +bower +bowls +bowse +boxed +boxer +boxes +boyar +boyla +boyos +bozos +brace +brach +bract +brads +braes +brags +braid +brail +brain +brake +braky +brand +brank +brans +brant +brash +brass +brats +brava +brave +bravi +bravo +brawl +brawn +braws +braxy +brays +braza +braze +bread +break +bream +brede +breed +brees +brens +brent +breve +brews +briar +bribe +brick +bride +brief +brier +bries +brigs +brill +brims +brine +bring +brink +brins +briny +brios +brisk +brits +britt +broad +brock +broil +broke +brome +bromo +bronc +brood +brook +broom +broos +brose +brosy +broth +brown +brows +brugh +bruin +bruit +brume +brunt +brush +brusk +brute +bubal +bubby +bucko +bucks +buddy +budge +buffi +buffo +buffs +buffy +buggy +bugle +buhls +buhrs +build +built +bulbs +bulge +bulgy +bulks +bulky +bulla +bulls +bully +bumfs +bumph +bumps +bumpy +bunch +bunco +bunds +bundt +bungs +bunko +bunks +bunns +bunny +bunts +bunya +buoys +buran +buras +burbs +burds +buret +burgh +burgs +burin +burke +burls +burly +burns +burnt +burps +burro +burrs +burry +bursa +burse +burst +busby +bused +buses +bushy +busks +busts +busty +butch +buteo +butle +butte +butts +butty +butut +butyl +buxom +buyer +bwana +bylaw +byres +byrls +byssi +bytes +byway +cabal +cabby +caber +cabin +cable +cabob +cacao +cacas +cache +cacti +caddy +cades +cadet +cadge +cadgy +cadis +cadre +caeca +cafes +caffs +caged +cager +cages +cagey +cahow +caids +cains +caird +cairn +cajon +caked +cakes +cakey +calfs +calif +calix +calks +calla +calls +calms +calve +calyx +camas +camel +cameo +cames +campi +campo +camps +campy +canal +candy +caned +caner +canes +canid +canna +canny +canoe +canon +canso +canst +canto +cants +canty +caped +caper +capes +caphs +capon +capos +caput +carat +carbo +carbs +cards +cared +carer +cares +caret +carex +cargo +carks +carle +carls +carns +carny +carob +carol +carom +carpi +carps +carrs +carry +carse +carte +carts +carve +casas +cased +cases +casks +casky +caste +casts +casus +catch +cater +cates +catty +cauld +caulk +cauls +cause +caved +caver +caves +cavie +cavil +cawed +cease +cebid +cecal +cecum +cedar +ceded +ceder +cedes +cedis +ceiba +ceils +celeb +cella +celli +cello +cells +celom +celts +cense +cento +cents +ceorl +cepes +cerci +cered +ceres +ceria +ceric +ceros +cesta +cesti +cetes +chads +chafe +chaff +chain +chair +chalk +champ +chams +chang +chant +chaos +chape +chaps +chapt +chard +chare +chark +charm +charr +chars +chart +chary +chase +chasm +chats +chaws +chays +cheap +cheat +check +cheek +cheep +cheer +chefs +chela +chemo +chert +chess +chest +cheth +chevy +chews +chewy +chiao +chias +chick +chico +chics +chide +chief +chiel +child +chile +chili +chill +chimb +chime +chimp +china +chine +chink +chino +chins +chips +chirk +chirm +chiro +chirp +chirr +chits +chive +chivy +chock +choir +choke +choky +cholo +chomp +chook +chops +chord +chore +chose +chott +chows +chubs +chuck +chufa +chuff +chugs +chump +chums +chunk +churl +churn +churr +chute +chyle +chyme +cibol +cider +cigar +cilia +cimex +cinch +cines +cions +circa +cires +cirri +cisco +cissy +cists +cited +citer +cites +civet +civic +civie +civil +civvy +clach +clack +clade +clads +clags +claim +clamp +clams +clang +clank +clans +claps +clapt +claro +clary +clash +clasp +class +clast +clave +clavi +claws +clays +clean +clear +cleat +cleek +clefs +cleft +clepe +clept +clerk +clews +click +cliff +clift +climb +clime +cline +cling +clink +clips +clipt +cloak +clock +clods +clogs +clomb +clomp +clone +clonk +clons +cloot +clops +close +cloth +clots +cloud +clour +clout +clove +clown +cloys +cloze +clubs +cluck +clued +clues +clump +clung +clunk +coach +coact +coala +coals +coaly +coapt +coast +coati +coats +cobbs +cobby +cobia +coble +cobra +cocas +cocci +cocks +cocky +cocoa +cocos +codas +codec +coded +coden +coder +codes +codex +codon +coeds +coffs +cogon +cohog +cohos +coifs +coign +coils +coins +coirs +coked +cokes +colas +colds +coled +coles +colic +colin +colly +colog +colon +color +colts +colza +comae +comal +comas +combe +combo +combs +comer +comes +comet +comfy +comic +comix +comma +commy +compo +comps +compt +comte +conch +condo +coned +cones +coney +conga +conge +congo +conic +conin +conks +conky +conns +conte +conto +conus +cooch +cooed +cooee +cooer +cooey +coofs +cooks +cooky +cools +cooly +coomb +coons +coops +coopt +coots +copal +coped +copen +coper +copes +copra +copse +coral +corby +cords +cored +corer +cores +corgi +coria +corks +corky +corms +corns +cornu +corny +corps +corse +cosec +coses +coset +cosey +cosie +costa +costs +cotan +coted +cotes +cotta +couch +coude +cough +could +count +coupe +coups +court +couth +coved +coven +cover +coves +covet +covey +covin +cowed +cower +cowls +cowry +coxae +coxal +coxed +coxes +coyed +coyer +coyly +coypu +cozen +cozes +cozey +cozie +craal +crabs +crack +craft +crags +crake +cramp +crams +crane +crank +crape +craps +crash +crass +crate +crave +crawl +craws +craze +crazy +creak +cream +credo +creed +creek +creel +creep +creme +crepe +crept +crepy +cress +crest +crews +cribs +crick +cried +crier +cries +crime +crimp +cripe +crisp +croak +croci +crock +crocs +croft +crone +crony +crook +croon +crops +crore +cross +croup +crowd +crown +crows +croze +cruck +crude +cruds +cruel +cruet +crumb +crump +cruor +crura +cruse +crush +crust +crwth +crypt +cubby +cubeb +cubed +cuber +cubes +cubic +cubit +cuddy +cuffs +cuifs +cuing +cuish +cukes +culch +culet +culex +culls +cully +culms +culpa +culti +cults +cumin +cunts +cupel +cupid +cuppa +cuppy +curbs +curch +curds +curdy +cured +curer +cures +curet +curfs +curia +curie +curio +curls +curly +curns +currs +curry +curse +curst +curve +curvy +cusec +cushy +cusks +cusps +cusso +cutch +cuter +cutes +cutey +cutie +cutin +cutis +cutty +cutup +cyano +cyans +cycad +cycas +cycle +cyclo +cyder +cylix +cymae +cymar +cymas +cymes +cymol +cynic +cysts +cyton +czars +daces +dacha +dadas +daddy +dados +daffs +daffy +dagga +dagos +dahls +daily +dairy +daisy +dales +dally +daman +damar +dames +damns +damps +dance +dandy +dangs +danio +darbs +dared +darer +dares +daric +darks +darky +darns +darts +dashi +dashy +dated +dater +dates +datos +datto +datum +daube +daubs +dauby +daunt +dauts +daven +davit +dawed +dawen +dawks +dawns +dawts +dazed +dazes +deads +deair +deals +dealt +deans +dears +deary +deash +death +deave +debar +debit +debts +debug +debut +debye +decaf +decal +decay +decks +decor +decos +decoy +decry +dedal +deeds +deedy +deems +deeps +deers +deets +defat +defer +defis +defog +degas +degum +deice +deify +deign +deils +deism +deist +deity +deked +dekes +dekko +delay +deled +deles +delfs +delft +delis +dells +delly +delta +delve +demes +demit +demob +demon +demos +demur +denes +denim +dense +dents +deoxy +depot +depth +derat +deray +derby +derma +derms +derry +desex +desks +deter +detox +deuce +devas +devel +devil +devon +dewan +dewar +dewax +dewed +dexes +dexie +dhaks +dhals +dhobi +dhole +dhoti +dhows +dhuti +dials +diary +diazo +diced +dicer +dices +dicey +dicks +dicky +dicot +dicta +dicty +didie +didos +didst +diene +diets +dight +digit +diked +diker +dikes +dikey +dildo +dills +dilly +dimer +dimes +dimly +dinar +dined +diner +dines +dinge +dingo +dings +dingy +dinks +dinky +dints +diode +diols +dippy +dipso +direr +dirge +dirks +dirls +dirts +dirty +disci +disco +discs +dishy +disks +disme +ditas +ditch +dites +ditsy +ditto +ditty +ditzy +divan +divas +dived +diver +dives +divot +divvy +diwan +dixit +dizen +dizzy +djinn +djins +doats +dobby +dobie +dobla +dobra +docks +dodge +dodgy +dodos +doers +doest +doeth +doffs +doges +dogey +doggo +doggy +dogie +dogma +doily +doing +doits +dojos +dolce +dolci +doled +doles +dolls +dolly +dolma +dolor +dolts +domal +domed +domes +domic +donas +donee +donga +dongs +donna +donne +donor +donsy +donut +dooly +dooms +doomy +doors +doozy +dopas +doped +doper +dopes +dopey +dorks +dorky +dorms +dormy +dorps +dorrs +dorsa +dorty +dosed +doser +doses +dotal +doted +doter +dotes +dotty +doubt +douce +dough +douma +doums +doura +douse +doven +doves +dowdy +dowed +dowel +dower +dowie +downs +downy +dowry +dowse +doxie +doyen +doyly +dozed +dozen +dozer +dozes +drabs +draff +draft +drags +drail +drain +drake +drama +drams +drank +drape +drats +drave +drawl +drawn +draws +drays +dread +dream +drear +dreck +dreed +drees +dregs +dreks +dress +drest +dribs +dried +drier +dries +drift +drill +drily +drink +drips +dript +drive +droit +droll +drone +drool +droop +drops +dropt +dross +drouk +drove +drown +drubs +drugs +druid +drums +drunk +drupe +druse +dryad +dryer +dryly +duads +duals +ducal +ducat +duces +duchy +ducks +ducky +ducts +duddy +duded +dudes +duels +duets +duffs +duits +duked +dukes +dulia +dulls +dully +dulse +dumas +dumbs +dumka +dumky +dummy +dumps +dumpy +dunam +dunce +dunch +dunes +dungs +dungy +dunks +dunts +duomi +duomo +duped +duper +dupes +duple +dural +duras +dured +dures +durns +duroc +duros +durra +durrs +durst +durum +dusks +dusky +dusts +dusty +dutch +duvet +dwarf +dweeb +dwell +dwelt +dwine +dyads +dyers +dying +dyked +dykes +dykey +dynel +dynes +eager +eagle +eagre +eared +earls +early +earns +earth +eased +easel +eases +easts +eaten +eater +eaved +eaves +ebbed +ebbet +ebons +ebony +eched +eches +echos +eclat +ecrus +edema +edged +edger +edges +edict +edify +edile +edits +educe +educt +eerie +egads +egers +egest +eggar +egged +egger +egret +eider +eidos +eight +eikon +eject +eking +elain +eland +elans +elate +elbow +elder +elect +elegy +elemi +elfin +elide +elint +elite +eloin +elope +elude +elute +elver +elves +embar +embay +embed +ember +embow +emcee +emeer +emend +emery +emeus +emirs +emits +emmer +emmet +emote +empty +emyde +emyds +enact +enate +ended +ender +endow +endue +enema +enemy +enjoy +ennui +enoki +enols +enorm +enows +enrol +ensky +ensue +enter +entia +entry +enure +envoi +envoy +enzym +eosin +epact +epees +ephah +ephas +ephod +ephor +epics +epoch +epode +epoxy +equal +equid +equip +erase +erect +ergot +erica +ernes +erode +erose +erred +error +erses +eruct +erugo +erupt +ervil +escar +escot +eskar +esker +essay +esses +ester +estop +etape +ether +ethic +ethos +ethyl +etnas +etude +etuis +etwee +etyma +euros +evade +evens +event +evert +every +evict +evils +evite +evoke +ewers +exact +exalt +exams +excel +execs +exert +exile +exine +exist +exits +exons +expat +expel +expos +extol +extra +exude +exult +exurb +eyers +eying +eyras +eyres +eyrie +eyrir +fable +faced +facer +faces +facet +facia +facts +faddy +faded +fader +fades +fadge +fados +faena +faery +faggy +fagin +fagot +fails +faint +fairs +fairy +faith +faked +faker +fakes +fakey +fakir +falls +false +famed +fames +fancy +fanes +fanga +fangs +fanny +fanon +fanos +fanum +faqir +farad +farce +farci +farcy +fards +fared +farer +fares +farle +farls +farms +faros +farts +fasts +fatal +fated +fates +fatly +fatso +fatty +fatwa +faugh +fauld +fault +fauna +fauns +fauve +favas +faves +favor +favus +fawns +fawny +faxed +faxes +fayed +fazed +fazes +fears +fease +feast +feats +feaze +fecal +feces +fecks +feeds +feels +feeze +feign +feint +feist +felid +fella +fells +felly +felon +felts +femes +femme +femur +fence +fends +fenny +feods +feoff +feral +feres +feria +ferly +fermi +ferns +ferny +ferry +fesse +fetal +fetas +fetch +feted +fetes +fetid +fetor +fetus +feuar +feuds +feued +fever +fewer +feyer +feyly +fezes +fiars +fiats +fiber +fibre +fices +fiche +fichu +ficin +ficus +fidge +fidos +fiefs +field +fiend +fiery +fifed +fifer +fifes +fifth +fifty +fight +filar +filch +filed +filer +files +filet +fille +fillo +fills +filly +films +filmy +filos +filth +filum +final +finch +finds +fined +finer +fines +finis +finks +finny +finos +fiord +fique +fired +firer +fires +firms +firns +firry +first +firth +fiscs +fishy +fists +fitch +fitly +fiver +fives +fixed +fixer +fixes +fixit +fizzy +fjeld +fjord +flabs +flack +flags +flail +flair +flake +flaky +flame +flams +flamy +flank +flans +flaps +flare +flash +flask +flats +flaws +flawy +flaxy +flays +fleam +fleas +fleck +fleer +flees +fleet +flesh +flews +fleys +flick +flics +flied +flier +flies +fling +flint +flips +flirt +flite +flits +float +flock +flocs +floes +flogs +flong +flood +floor +flops +flora +floss +flota +flour +flout +flown +flows +flubs +flued +flues +fluff +fluid +fluke +fluky +flume +flump +flung +flunk +fluor +flush +flute +fluty +fluyt +flyby +flyer +flyte +foals +foams +foamy +focal +focus +foehn +fogey +foggy +fogie +fohns +foils +foins +foist +folds +folia +folio +folks +folky +folly +fonds +fondu +fonts +foods +fools +foots +footy +foram +foray +forbs +forby +force +fordo +fords +fores +forge +forgo +forks +forky +forme +forms +forte +forth +forts +forty +forum +fossa +fosse +fouls +found +fount +fours +fovea +fowls +foxed +foxes +foyer +frags +frail +frame +franc +frank +fraps +frass +frats +fraud +frays +freak +freed +freer +frees +fremd +frena +frere +fresh +frets +friar +fried +frier +fries +frigs +frill +frise +frisk +frith +frits +fritt +fritz +frizz +frock +froes +frogs +frond +frons +front +frore +frosh +frost +froth +frown +frows +froze +frugs +fruit +frump +fryer +fubsy +fucks +fucus +fudge +fuels +fugal +fuggy +fugio +fugle +fugue +fugus +fujis +fulls +fully +fumed +fumer +fumes +fumet +fundi +funds +fungi +fungo +funks +funky +funny +furan +furls +furor +furry +furze +furzy +fused +fusee +fusel +fuses +fusil +fussy +fusty +futon +fuzed +fuzee +fuzes +fuzil +fuzzy +fyces +fykes +fytte +gabby +gable +gaddi +gadid +gadis +gaffe +gaffs +gaged +gager +gages +gaily +gains +gaits +galah +galas +galax +galea +gales +galls +gally +galop +gamas +gamay +gamba +gambe +gambs +gamed +gamer +games +gamey +gamic +gamin +gamma +gammy +gamps +gamut +ganef +ganev +gangs +ganja +ganof +gaols +gaped +gaper +gapes +gappy +garbs +garni +garth +gases +gasps +gassy +gasts +gated +gates +gator +gauds +gaudy +gauge +gault +gaums +gaunt +gaurs +gauss +gauze +gauzy +gavel +gavot +gawks +gawky +gawps +gawsy +gayal +gayer +gayly +gazar +gazed +gazer +gazes +gears +gecko +gecks +geeks +geeky +geese +geest +gelds +gelee +gelid +gelts +gemma +gemmy +gemot +genes +genet +genic +genie +genii +genip +genoa +genom +genre +genro +gents +genua +genus +geode +geoid +gerah +germs +germy +gesso +geste +gests +getas +getup +geums +ghast +ghats +ghaut +ghazi +ghees +ghost +ghoul +ghyll +giant +gibed +giber +gibes +giddy +gifts +gigas +gighe +gigot +gigue +gilds +gills +gilly +gilts +gimel +gimme +gimps +gimpy +ginks +ginny +gipon +gipsy +girds +girls +girly +girns +giron +giros +girsh +girth +girts +gismo +gists +given +giver +gives +gizmo +glace +glade +glads +glady +glair +gland +glans +glare +glary +glass +glaze +glazy +gleam +glean +gleba +glebe +glede +gleds +gleed +gleek +glees +gleet +glens +gleys +glial +glias +glide +gliff +glime +glims +glint +glitz +gloam +gloat +globe +globs +glogg +gloms +gloom +glops +glory +gloss +glost +glout +glove +glows +gloze +glued +gluer +glues +gluey +glugs +glume +gluon +gluts +glyph +gnarl +gnarr +gnars +gnash +gnats +gnawn +gnaws +gnome +goads +goals +goats +goban +gobos +godet +godly +goers +gofer +gogos +going +golds +golem +golfs +golly +gombo +gonad +gonef +goner +gongs +gonia +gonif +gonof +gonzo +goods +goody +gooey +goofs +goofy +gooks +gooky +goons +goony +goops +goopy +goose +goosy +goral +gored +gores +gorge +gorps +gorse +gorsy +gouge +gourd +gouts +gouty +gowan +gowds +gowks +gowns +goxes +goyim +graal +grabs +grace +grade +grads +graft +grail +grain +grama +gramp +grams +grana +grand +grans +grant +grape +graph +grapy +grasp +grass +grate +grave +gravy +grays +graze +great +grebe +greed +greek +green +grees +greet +grego +greys +gride +grids +grief +griff +grift +grigs +grill +grime +grimy +grind +grins +griot +gripe +grips +gript +gripy +grist +grith +grits +groan +groat +grogs +groin +groom +grope +gross +grosz +grots +group +grout +grove +growl +grown +grows +grubs +gruel +grues +gruff +grume +grump +grunt +guaco +guano +guans +guard +guars +guava +gucks +gudes +guess +guest +guffs +guide +guids +guild +guile +guilt +guiro +guise +gulag +gular +gulch +gules +gulfs +gulfy +gulls +gully +gulps +gulpy +gumbo +gumma +gummy +gunks +gunky +gunny +guppy +gurge +gurry +gursh +gurus +gushy +gussy +gusto +gusts +gusty +gutsy +gutta +gutty +guyed +guyot +gybed +gybes +gypsy +gyral +gyred +gyres +gyron +gyros +gyrus +gyved +gyves +haafs +haars +habit +habus +hacek +hacks +hadal +haded +hades +hadji +hadst +haems +haets +hafis +hafiz +hafts +hahas +haika +haiks +haiku +hails +hairs +hairy +hajes +hajis +hajji +hakes +hakim +haled +haler +hales +halid +hallo +halls +halma +halms +halos +halts +halva +halve +hamal +hames +hammy +hamza +hance +hands +handy +hangs +hanks +hanky +hansa +hanse +hants +haole +hapax +haply +happy +hards +hardy +hared +harem +hares +harks +harls +harms +harps +harpy +harry +harsh +harts +hasps +haste +hasty +hatch +hated +hater +hates +haugh +haulm +hauls +haunt +haute +haven +haver +haves +havoc +hawed +hawks +hawse +hayed +hayer +hazan +hazed +hazel +hazer +hazes +heads +heady +heals +heaps +heard +hears +heart +heath +heats +heave +heavy +hebes +hecks +heder +hedge +hedgy +heeds +heels +heeze +hefts +hefty +heigh +heils +heirs +heist +helio +helix +hello +hells +helms +helos +helot +helps +helve +hemal +hemes +hemic +hemin +hemps +hempy +hence +henna +henry +hents +herbs +herby +herds +heres +herls +herma +herms +herns +heron +heros +herry +hertz +hests +heths +heuch +heugh +hewed +hewer +hexad +hexed +hexer +hexes +hexyl +hicks +hided +hider +hides +highs +hight +hiked +hiker +hikes +hilar +hillo +hills +hilly +hilts +hilum +hilus +hinds +hinge +hinny +hints +hippo +hippy +hired +hirer +hires +hissy +hists +hitch +hived +hives +hoagy +hoard +hoars +hoary +hobby +hobos +hocks +hocus +hodad +hoers +hogan +hoggs +hoick +hoise +hoist +hoked +hokes +hokey +hokku +hokum +holds +holed +holes +holey +holks +holla +hollo +holly +holms +holts +homed +homer +homes +homey +homos +honan +honda +honed +honer +hones +honey +hongs +honks +honky +honor +hooch +hoods +hoody +hooey +hoofs +hooka +hooks +hooky +hooly +hoops +hoots +hooty +hoped +hoper +hopes +hoppy +horah +horal +horas +horde +horns +horny +horse +horst +horsy +hosed +hosel +hosen +hoses +hosta +hosts +hotch +hotel +hotly +hound +houri +hours +house +hovel +hover +howdy +howes +howff +howfs +howks +howls +hoyas +hoyle +hubby +hucks +huffs +huffy +huger +hulas +hulks +hulky +hullo +hulls +human +humic +humid +humor +humph +humps +humpy +humus +hunch +hunks +hunky +hunts +hurds +hurls +hurly +hurry +hurst +hurts +husks +husky +hussy +hutch +huzza +hydra +hydro +hyena +hying +hylas +hymen +hymns +hyoid +hyped +hyper +hypes +hypha +hypos +hyrax +hyson +iambi +iambs +ichor +icier +icily +icing +icker +icons +ictic +ictus +ideal +ideas +idiom +idiot +idled +idler +idles +idols +idyll +idyls +igloo +iglus +ihram +ikats +ikons +ileac +ileal +ileum +ileus +iliac +iliad +ilial +ilium +iller +image +imago +imams +imaum +imbed +imbue +imide +imido +imids +imine +imino +immix +imped +impel +impis +imply +inane +inapt +inarm +inbye +incog +incur +incus +index +indie +indol +indow +indri +indue +inept +inert +infer +infix +infos +infra +ingle +ingot +inion +inked +inker +inkle +inlay +inlet +inned +inner +input +inset +inter +intis +intro +inure +inurn +invar +iodic +iodid +iodin +ionic +iotas +irade +irate +irids +iring +irked +iroko +irone +irons +irony +isbas +isled +isles +islet +issei +issue +istle +itchy +items +ither +ivied +ivies +ivory +ixias +ixora +ixtle +izars +jabot +jacal +jacks +jacky +jaded +jades +jager +jaggs +jaggy +jagra +jails +jakes +jalap +jalop +jambe +jambs +jammy +janes +janty +japan +japed +japer +japes +jarls +jatos +jauks +jaunt +jaups +javas +jawan +jawed +jazzy +jeans +jebel +jeeps +jeers +jefes +jehad +jehus +jells +jelly +jemmy +jenny +jerid +jerks +jerky +jerry +jesse +jests +jetes +jeton +jetty +jewed +jewel +jibbs +jibed +jiber +jibes +jiffs +jiffy +jihad +jills +jilts +jimmy +jimpy +jingo +jinks +jinni +jinns +jisms +jived +jiver +jives +jivey +jnana +jocko +jocks +joeys +johns +joins +joint +joist +joked +joker +jokes +jokey +joles +jolly +jolts +jolty +jones +joram +jorum +jotas +jotty +joual +jouks +joule +joust +jowar +jowed +jowls +jowly +joyed +jubas +jubes +judas +judge +judos +jugal +jugum +juice +juicy +jujus +juked +jukes +julep +jumbo +jumps +jumpy +junco +junks +junky +junta +junto +jupes +jupon +jural +jurat +jurel +juror +justs +jutes +jutty +kabab +kabar +kabob +kadis +kafir +kagus +kaiak +kaifs +kails +kains +kakas +kakis +kalam +kales +kalif +kalpa +kames +kamik +kanas +kanes +kanji +kaons +kapas +kaphs +kapok +kappa +kaput +karat +karma +karns +karoo +karst +karts +kasha +katas +kauri +kaury +kavas +kayak +kayos +kazoo +kbars +kebab +kebar +kebob +kecks +kedge +keefs +keeks +keels +keens +keeps +keets +keeve +kefir +keirs +kelep +kelim +kelly +kelps +kelpy +kemps +kempt +kenaf +kench +kendo +kenos +kepis +kerbs +kerfs +kerne +kerns +kerry +ketch +ketol +kevel +kevil +kexes +keyed +khadi +khafs +khaki +khans +khaph +khats +kheda +kheth +khets +khoum +kiang +kibbe +kibbi +kibei +kibes +kibla +kicks +kicky +kiddo +kiddy +kiefs +kiers +kikes +kilim +kills +kilns +kilos +kilts +kilty +kinas +kinds +kines +kings +kinin +kinks +kinky +kinos +kiosk +kirks +kirns +kissy +kists +kited +kiter +kites +kithe +kiths +kitty +kivas +kiwis +klong +kloof +kluge +klutz +knack +knaps +knars +knaur +knave +knead +kneed +kneel +knees +knell +knelt +knife +knish +knits +knobs +knock +knoll +knops +knosp +knots +knout +known +knows +knurl +knurs +koala +koans +koels +kohls +koine +kolas +kolos +konks +kooks +kooky +kopek +kophs +kopje +koppa +korai +korat +korun +kotos +kotow +kraal +kraft +krait +kraut +kreep +krill +krona +krone +kroon +krubi +kudos +kudus +kudzu +kugel +kukri +kulak +kumys +kurta +kurus +kusso +kvass +kyack +kyaks +kyars +kyats +kylix +kyrie +kytes +kythe +laari +label +labia +labor +labra +laced +lacer +laces +lacey +lacks +laded +laden +lader +lades +ladle +laevo +lagan +lager +lahar +laich +laics +laigh +laird +lairs +laith +laity +laked +laker +lakes +lakhs +lalls +lamas +lambs +lamby +lamed +lamer +lames +lamia +lamps +lanai +lance +lands +lanes +lanky +lapel +lapin +lapis +lapse +larch +lards +lardy +laree +lares +large +largo +laris +larks +larky +larum +larva +lased +laser +lases +lasso +lasts +latch +lated +laten +later +latex +lathe +lathi +laths +lathy +latke +latte +lauan +lauds +laugh +laura +lavas +laved +laver +laves +lawed +lawns +lawny +laxer +laxly +layed +layer +layup +lazar +lazed +lazes +leach +leads +leady +leafs +leafy +leaks +leaky +leans +leant +leaps +leapt +learn +lears +leary +lease +leash +least +leave +leavy +leben +ledge +ledgy +leech +leeks +leers +leery +leets +lefts +lefty +legal +leger +leges +leggy +legit +lehrs +lehua +leman +lemma +lemon +lemur +lends +lenes +lenis +lenos +lense +lento +leone +leper +lepta +letch +lethe +letup +leuds +levee +level +lever +levin +lewis +lexes +lexis +lezzy +liana +liane +liang +liard +liars +libel +liber +libra +libri +lichi +licht +licit +licks +lidar +lidos +liege +liens +liers +lieus +lieve +lifer +lifts +ligan +liger +light +liked +liken +liker +likes +lilac +lilts +liman +limas +limba +limbi +limbo +limbs +limby +limed +limen +limes +limey +limit +limns +limos +limpa +limps +linac +lindy +lined +linen +liner +lines +liney +linga +lingo +lings +lingy +linin +links +linky +linns +linos +lints +linty +linum +lions +lipid +lipin +lippy +liras +lirot +lisle +lisps +lists +litai +litas +liter +lithe +litho +litre +lived +liven +liver +lives +livid +livre +llama +llano +loach +loads +loafs +loams +loamy +loans +loath +lobar +lobby +lobed +lobes +lobos +local +lochs +locks +locos +locum +locus +loden +lodes +lodge +loess +lofts +lofty +logan +loges +loggy +logia +logic +logoi +logos +loins +lolls +lolly +loner +longe +longs +looby +looed +looey +loofa +loofs +looie +looks +looms +loons +loony +loops +loopy +loose +loots +loped +loper +lopes +loppy +loral +loran +lords +lores +loris +lorry +losel +loser +loses +lossy +lotah +lotas +lotic +lotos +lotte +lotto +lotus +lough +louie +louis +loupe +loups +lours +loury +louse +lousy +louts +lovat +loved +lover +loves +lowed +lower +lowes +lowly +lowse +loxed +loxes +loyal +luaus +lubes +luces +lucid +lucks +lucky +lucre +ludes +ludic +luffa +luffs +luged +luger +luges +lulls +lulus +lumen +lumps +lumpy +lunar +lunas +lunch +lunes +lunet +lunge +lungi +lungs +lunks +lunts +lupin +lupus +lurch +lured +lurer +lures +lurid +lurks +lusts +lusty +lusus +lutea +luted +lutes +luxes +lweis +lyard +lyart +lyase +lycea +lycee +lying +lymph +lynch +lyres +lyric +lysed +lyses +lysin +lysis +lyssa +lytic +lytta +maars +mabes +macaw +maced +macer +maces +mache +macho +machs +macks +macle +macon +macro +madam +madly +madre +mafia +mafic +mages +magic +magma +magot +magus +mahoe +maids +maile +maill +mails +maims +mains +mairs +maist +maize +major +makar +maker +makes +makos +malar +males +malic +malls +malms +malmy +malts +malty +mamas +mamba +mambo +mamey +mamie +mamma +mammy +manas +maned +manes +mange +mango +mangy +mania +manic +manly +manna +manor +manos +manse +manta +manus +maple +maqui +march +marcs +mares +marge +maria +marks +marls +marly +marry +marse +marsh +marts +marvy +maser +mashy +masks +mason +massa +masse +massy +masts +match +mated +mater +mates +matey +maths +matin +matte +matts +matza +matzo +mauds +mauls +maund +mauts +mauve +maven +mavie +mavin +mavis +mawed +maxes +maxim +maxis +mayan +mayas +maybe +mayed +mayor +mayos +mayst +mazed +mazer +mazes +mbira +meads +meals +mealy +means +meant +meany +meats +meaty +mecca +medal +media +medic +medii +meeds +meets +meiny +melds +melee +melic +mells +melon +melts +memos +menad +mends +mensa +mense +menta +menus +meous +meows +mercy +merde +merer +meres +merge +merit +merks +merle +merls +merry +mesas +meshy +mesic +mesne +meson +messy +metal +meted +meter +metes +meths +metis +metre +metro +mewed +mewls +mezes +mezzo +miaou +miaow +miasm +miaul +micas +miche +micks +micra +micro +middy +midge +midis +midst +miens +miffs +miffy +miggs +might +miked +mikes +mikra +milch +miler +miles +milia +milks +milky +mille +mills +milos +milpa +milts +milty +mimed +mimeo +mimer +mimes +mimic +minae +minas +mince +mincy +minds +mined +miner +mines +mingy +minim +minis +minke +minks +minny +minor +mints +minty +minus +mired +mires +mirex +mirks +mirky +mirth +mirza +misdo +miser +mises +misos +missy +mists +misty +miter +mites +mitis +mitre +mitts +mixed +mixer +mixes +mixup +mizen +moans +moats +mocha +mocks +modal +model +modem +modes +modus +moggy +mogul +mohel +mohur +moils +moira +moire +moist +mojos +mokes +molal +molar +molas +molds +moldy +moles +molls +molly +molto +molts +momes +momma +mommy +momus +monad +monas +monde +mondo +money +mongo +monie +monks +monos +monte +month +mooch +moods +moody +mooed +moola +mools +moons +moony +moors +moory +moose +moots +moped +moper +mopes +mopey +morae +moral +moras +moray +morel +mores +morns +moron +morph +morro +morse +morts +mosey +mosks +mosso +mossy +moste +mosts +motel +motes +motet +motey +moths +mothy +motif +motor +motte +motto +motts +mouch +moues +mould +moult +mound +mount +mourn +mouse +mousy +mouth +moved +mover +moves +movie +mowed +mower +moxas +moxie +mozos +mucid +mucin +mucks +mucky +mucor +mucro +mucus +muddy +mudra +muffs +mufti +muggs +muggy +muhly +mujik +mulch +mulct +muled +mules +muley +mulla +mulls +mumms +mummy +mumps +mumus +munch +mungo +munis +muons +mural +muras +mured +mures +murex +murid +murks +murky +murra +murre +murrs +murry +musca +mused +muser +muses +mushy +music +musks +musky +mussy +musth +musts +musty +mutch +muted +muter +mutes +muton +mutts +muzzy +mynah +mynas +myoid +myoma +myope +myopy +myrrh +mysid +myths +mythy +naans +nabes +nabis +nabob +nacho +nacre +nadas +nadir +naevi +naggy +naiad +naifs +nails +naira +naive +naked +naled +named +namer +names +nanas +nance +nancy +nanny +napes +nappe +nappy +narco +narcs +nards +nares +naric +naris +narks +narky +nasal +nasty +natal +natch +nates +natty +naval +navar +navel +naves +navvy +nawab +nazis +neaps +nears +neath +neats +necks +needs +needy +neems +neeps +negus +neifs +neigh +neist +nelly +nemas +neons +nerds +nerdy +nerol +nerts +nertz +nerve +nervy +nests +netop +netts +netty +neuks +neume +neums +never +neves +nevus +newel +newer +newie +newly +newsy +newts +nexus +ngwee +nicad +nicer +niche +nicks +nicol +nidal +nided +nides +nidus +niece +nieve +nifty +nighs +night +nihil +nills +nimbi +nines +ninja +ninny +ninon +ninth +nipas +nippy +nisei +nisus +niter +nites +nitid +niton +nitre +nitro +nitty +nival +nixed +nixes +nixie +nizam +nobby +noble +nobly +nocks +nodal +noddy +nodes +nodus +noels +noggs +nohow +noils +noily +noirs +noise +noisy +nolos +nomad +nomas +nomen +nomes +nomoi +nomos +nonas +nonce +nones +nonet +nonyl +nooks +nooky +noons +noose +nopal +noria +noris +norms +north +nosed +noses +nosey +notal +notch +noted +noter +notes +notum +nouns +novae +novas +novel +noway +nowts +nubby +nubia +nucha +nuder +nudes +nudge +nudie +nudzh +nuked +nukes +nulls +numbs +numen +nurds +nurls +nurse +nutsy +nutty +nyala +nylon +nymph +oaken +oakum +oared +oases +oasis +oasts +oaten +oater +oaths +oaves +obeah +obeli +obese +obeys +obias +obits +objet +oboes +obole +oboli +obols +occur +ocean +ocher +ochre +ochry +ocker +ocrea +octad +octal +octan +octet +octyl +oculi +odder +oddly +odeon +odeum +odist +odium +odors +odour +odyle +odyls +ofays +offal +offed +offer +often +ofter +ogams +ogees +ogham +ogive +ogled +ogler +ogles +ogres +ohias +ohing +ohmic +oidia +oiled +oiler +oinks +okapi +okays +okehs +okras +olden +older +oldie +oleic +olein +oleos +oleum +olios +olive +ollas +ology +omasa +omber +ombre +omega +omens +omers +omits +onery +onion +onium +onset +ontic +oohed +oomph +oorie +ootid +oozed +oozes +opahs +opals +opens +opera +opine +oping +opium +opsin +opted +optic +orach +orals +orang +orate +orbed +orbit +orcas +orcin +order +ordos +oread +organ +orgic +oribi +oriel +orles +orlop +ormer +ornis +orpin +orris +ortho +orzos +osier +osmic +osmol +ossia +ostia +other +ottar +otter +ottos +ought +ounce +ouphe +ouphs +ourie +ousel +ousts +outby +outdo +outed +outer +outgo +outre +ouzel +ouzos +ovals +ovary +ovate +ovens +overs +overt +ovine +ovoid +ovoli +ovolo +ovule +owing +owlet +owned +owner +owsen +oxbow +oxeye +oxide +oxids +oxime +oxims +oxlip +oxter +oyers +ozone +pacas +paced +pacer +paces +pacha +packs +pacts +paddy +padis +padle +padre +padri +paean +paeon +pagan +paged +pager +pages +pagod +paiks +pails +pains +paint +pairs +paisa +paise +palea +paled +paler +pales +palet +palls +pally +palms +palmy +palpi +palps +palsy +pampa +panda +pandy +paned +panel +panes +panga +pangs +panic +panne +pansy +panto +pants +panty +papal +papas +papaw +paper +pappi +pappy +paras +parch +pardi +pards +pardy +pared +pareo +parer +pares +pareu +parge +pargo +paris +parka +parks +parle +parol +parrs +parry +parse +parts +party +parve +parvo +paseo +pases +pasha +passe +pasta +paste +pasts +pasty +patch +pated +paten +pater +pates +paths +patin +patio +patly +patsy +patty +pause +pavan +paved +paver +paves +pavid +pavin +pavis +pawed +pawer +pawky +pawls +pawns +paxes +payed +payee +payer +payor +peace +peach +peage +peags +peaks +peaky +peals +peans +pearl +pears +peart +pease +peats +peaty +peavy +pecan +pechs +pecks +pecky +pedal +pedes +pedro +peeks +peels +peens +peeps +peers +peery +peeve +peins +peise +pekan +pekes +pekin +pekoe +peles +pelfs +pelon +pelts +penal +pence +pends +penes +pengo +penis +penna +penne +penni +penny +peons +peony +pepla +pepos +peppy +perch +perdu +perdy +perea +peril +peris +perks +perky +perms +perry +perse +pesky +pesos +pesto +pests +pesty +petal +peter +petit +petti +petto +petty +pewee +pewit +phage +phase +phial +phlox +phone +phono +phons +phony +photo +phots +phpht +phuts +phyla +phyle +piano +pians +pibal +pical +picas +picks +picky +picot +picul +piece +piers +pieta +piety +piggy +pigmy +piing +pikas +piked +piker +pikes +pikis +pilaf +pilar +pilau +pilaw +pilea +piled +pilei +piles +pilis +pills +pilot +pilus +pimas +pimps +pinas +pinch +pined +pines +piney +pingo +pings +pinko +pinks +pinky +pinna +pinny +pinon +pinot +pinta +pinto +pints +pinup +pions +pious +pipal +piped +piper +pipes +pipet +pipit +pique +pirns +pirog +pisco +pisos +piste +pitas +pitch +piths +pithy +piton +pivot +pixel +pixes +pixie +pizza +place +plack +plage +plaid +plain +plait +plane +plank +plans +plant +plash +plasm +plate +plats +platy +playa +plays +plaza +plead +pleas +pleat +plebe +plebs +plena +plews +plica +plied +plier +plies +plink +plods +plonk +plops +plots +plotz +plows +ploys +pluck +plugs +plumb +plume +plump +plums +plumy +plunk +plush +plyer +poach +pocks +pocky +podgy +podia +poems +poesy +poets +pogey +poilu +poind +point +poise +poked +poker +pokes +pokey +polar +poled +poler +poles +polio +polis +polka +polls +polos +polyp +polys +pomes +pommy +pomps +ponce +ponds +pones +pongs +pooch +poods +poofs +poofy +poohs +pools +poons +poops +poori +poove +popes +poppa +poppy +popsy +porch +pored +pores +porgy +porks +porky +porno +porns +porny +ports +posed +poser +poses +posit +posse +posts +potsy +potto +potty +pouch +pouff +poufs +poult +pound +pours +pouts +pouty +power +poxed +poxes +poyou +praam +prahu +prams +prang +prank +praos +prase +prate +prats +praus +prawn +prays +preed +preen +prees +preps +presa +prese +press +prest +prexy +preys +price +prick +pricy +pride +pried +prier +pries +prigs +prill +prima +prime +primi +primo +primp +prims +prink +print +prion +prior +prise +prism +priss +privy +prize +proas +probe +prods +proem +profs +progs +prole +promo +proms +prone +prong +proof +props +prose +proso +pross +prost +prosy +proud +prove +prowl +prows +proxy +prude +prune +pruta +pryer +psalm +pseud +pshaw +psoae +psoai +psoas +psych +pubes +pubic +pubis +puces +pucka +pucks +pudgy +pudic +puffs +puffy +puggy +pujah +pujas +puked +pukes +pukka +puled +puler +pules +pulik +pulis +pulls +pulps +pulpy +pulse +pumas +pumps +punas +punch +pungs +punka +punks +punky +punny +punto +punts +punty +pupae +pupal +pupas +pupil +puppy +purda +puree +purer +purge +purin +puris +purls +purrs +purse +pursy +puses +pushy +pussy +puton +putti +putto +putts +putty +pygmy +pyins +pylon +pyoid +pyran +pyres +pyric +pyxes +pyxie +pyxis +qaids +qanat +qophs +quack +quads +quaff +quags +quail +quais +quake +quaky +quale +qualm +quant +quare +quark +quart +quash +quasi +quass +quate +quays +quean +queen +queer +quell +quern +query +quest +queue +queys +quick +quids +quiet +quiff +quill +quilt +quins +quint +quips +quipu +quire +quirk +quirt +quite +quits +quods +quoin +quoit +quota +quote +quoth +qursh +rabat +rabbi +rabic +rabid +raced +racer +races +racks +racon +radar +radii +radio +radix +radon +raffs +rafts +ragas +raged +ragee +rages +raggy +ragis +raias +raids +rails +rains +rainy +raise +rajah +rajas +rajes +raked +rakee +raker +rakes +rakis +rales +rally +ralph +ramee +ramet +ramie +rammy +ramps +ramus +rance +ranch +rands +randy +ranee +range +rangy +ranid +ranis +ranks +rants +raped +raper +rapes +raphe +rapid +rared +rarer +rares +rased +raser +rases +rasps +raspy +ratal +ratan +ratch +rated +ratel +rater +rates +rathe +ratio +ratos +ratty +raved +ravel +raven +raver +raves +ravin +rawer +rawin +rawly +raxed +raxes +rayah +rayas +rayed +rayon +razed +razee +razer +razes +razor +reach +react +readd +reads +ready +realm +reals +reams +reaps +rearm +rears +reata +reave +rebar +rebbe +rebec +rebel +rebid +rebop +rebus +rebut +rebuy +recap +recce +recks +recon +recta +recti +recto +recur +recut +redan +redds +reded +redes +redia +redid +redip +redly +redon +redos +redox +redry +redub +redux +redye +reeds +reedy +reefs +reefy +reeks +reeky +reels +reest +reeve +refed +refel +refer +refit +refix +refly +refry +regal +reges +regma +regna +rehab +rehem +reifs +reify +reign +reink +reins +reive +rekey +relax +relay +relet +relic +relit +reman +remap +remet +remex +remit +remix +renal +rends +renew +renig +renin +rente +rents +reoil +repay +repeg +repel +repin +reply +repos +repot +repps +repro +reran +rerig +rerun +resaw +resay +resee +reset +resew +resid +resin +resod +resow +rests +retag +retax +retch +retem +retia +retie +retro +retry +reuse +revel +revet +revue +rewan +rewax +rewed +rewet +rewin +rewon +rexes +rheas +rheum +rhino +rhomb +rhumb +rhyme +rhyta +rials +riant +riata +ribby +ribes +riced +ricer +rices +ricin +ricks +rider +rides +ridge +ridgy +riels +rifer +riffs +rifle +rifts +right +rigid +rigor +riled +riles +riley +rille +rills +rimed +rimer +rimes +rinds +rings +rinks +rinse +rioja +riots +riped +ripen +riper +ripes +risen +riser +rises +rishi +risks +risky +risus +rites +ritzy +rival +rived +riven +river +rives +rivet +riyal +roach +roads +roams +roans +roars +roast +robed +robes +robin +roble +robot +rocks +rocky +rodeo +roger +rogue +roils +roily +roles +rolfs +rolls +roman +romeo +romps +rondo +roods +roofs +rooks +rooky +rooms +roomy +roose +roost +roots +rooty +roped +roper +ropes +ropey +roque +rosed +roses +roset +rosin +rotas +rotch +rotes +rotis +rotls +rotor +rotos +rotte +rouen +roues +rouge +rough +round +roups +roupy +rouse +roust +route +routh +routs +roved +roven +rover +roves +rowan +rowdy +rowed +rowel +rowen +rower +rowth +royal +ruana +rubes +ruble +rubus +ruche +rucks +rudds +ruddy +ruder +ruers +ruffe +ruffs +rugae +rugal +rugby +ruing +ruins +ruled +ruler +rules +rumba +rumen +rummy +rumor +rumps +runes +rungs +runic +runny +runts +runty +rupee +rural +ruses +rushy +rusks +rusts +rusty +ruths +rutin +rutty +ryked +rykes +rynds +ryots +sabed +saber +sabes +sabin +sabir +sable +sabot +sabra +sabre +sacks +sacra +sades +sadhe +sadhu +sadis +sadly +safer +safes +sagas +sager +sages +saggy +sagos +sagum +sahib +saice +saids +saiga +sails +sains +saint +saith +sajou +saker +sakes +sakis +salad +salal +salep +sales +salic +sally +salmi +salol +salon +salpa +salps +salsa +salts +salty +salve +salvo +samba +sambo +samek +samps +sands +sandy +saned +saner +sanes +sanga +sangh +santo +sapid +sapor +sappy +saran +sards +saree +sarge +sarin +saris +sarks +sarky +sarod +saros +sasin +sassy +satay +sated +satem +sates +satin +satis +satyr +sauce +sauch +saucy +saugh +sauls +sault +sauna +saury +saute +saved +saver +saves +savin +savor +savoy +savvy +sawed +sawer +saxes +sayer +sayid +sayst +scabs +scads +scags +scald +scale +scall +scalp +scaly +scamp +scams +scans +scant +scape +scare +scarf +scarp +scars +scart +scary +scats +scatt +scaup +scaur +scena +scend +scene +scent +schav +schmo +schul +schwa +scion +scoff +scold +scone +scoop +scoot +scope +scops +score +scorn +scots +scour +scout +scowl +scows +scrag +scram +scrap +scree +screw +scrim +scrip +scrod +scrub +scrum +scuba +scudi +scudo +scuds +scuff +sculk +scull +sculp +scums +scups +scurf +scuta +scute +scuts +seals +seams +seamy +sears +seats +sebum +secco +sects +sedan +seder +sedge +sedgy +sedum +seeds +seedy +seeks +seels +seely +seems +seeps +seepy +seers +segni +segno +segos +segue +seifs +seine +seise +seism +seize +selah +selfs +selle +sells +selva +semen +semes +semis +sends +sengi +senna +senor +sensa +sense +sente +senti +sepal +sepia +sepic +sepoy +septa +septs +serac +serai +seral +sered +serer +seres +serfs +serge +serif +serin +serow +serry +serum +serve +servo +setae +setal +seton +setts +setup +seven +sever +sewan +sewar +sewed +sewer +sexed +sexes +sexto +sexts +shack +shade +shads +shady +shaft +shags +shahs +shake +shako +shaky +shale +shall +shalt +shaly +shame +shams +shank +shape +shard +share +shark +sharn +sharp +shaul +shave +shawl +shawm +shawn +shaws +shays +sheaf +sheal +shear +sheas +sheds +sheen +sheep +sheer +sheet +sheik +shelf +shell +shend +shent +sheol +sherd +shewn +shews +shied +shiel +shier +shies +shift +shill +shily +shims +shine +shins +shiny +ships +shire +shirk +shirr +shirt +shist +shits +shiva +shive +shivs +shlep +shoal +shoat +shock +shoed +shoer +shoes +shogs +shoji +shone +shook +shool +shoon +shoos +shoot +shops +shore +shorl +shorn +short +shote +shots +shott +shout +shove +shown +shows +showy +shoyu +shred +shrew +shris +shrub +shrug +shtik +shuck +shuln +shuls +shuns +shunt +shush +shute +shuts +shyer +shyly +sials +sibbs +sibyl +sices +sicko +sicks +sided +sides +sidle +siege +sieur +sieve +sifts +sighs +sight +sigil +sigma +signs +siker +sikes +silds +silex +silks +silky +sills +silly +silos +silts +silty +silva +simar +simas +simps +since +sines +sinew +singe +sings +sinhs +sinks +sinus +siped +sipes +sired +siree +siren +sires +sirra +sirup +sisal +sises +sissy +sitar +sited +sites +situp +situs +siver +sixes +sixmo +sixte +sixth +sixty +sizar +sized +sizer +sizes +skags +skald +skate +skats +skean +skeed +skeen +skees +skeet +skegs +skein +skelm +skelp +skene +skeps +skews +skids +skied +skier +skies +skiey +skiff +skill +skimo +skimp +skims +skink +skins +skint +skips +skirl +skirr +skirt +skite +skits +skive +skoal +skosh +skuas +skulk +skull +skunk +skyed +skyey +slabs +slack +slags +slain +slake +slams +slang +slank +slant +slaps +slash +slate +slats +slaty +slave +slaws +slays +sleds +sleek +sleep +sleet +slept +slews +slice +slick +slide +slier +slily +slime +slims +slimy +sling +slink +slipe +slips +slipt +slits +slobs +sloes +slogs +sloid +slojd +sloop +slope +slops +slosh +sloth +slots +slows +sloyd +slubs +slued +slues +sluff +slugs +slump +slums +slung +slunk +slurb +slurp +slurs +slush +sluts +slyer +slyly +slype +smack +small +smalt +smarm +smart +smash +smaze +smear +smeek +smell +smelt +smerk +smews +smile +smirk +smite +smith +smock +smogs +smoke +smoky +smolt +smote +smuts +snack +snafu +snags +snail +snake +snaky +snaps +snare +snark +snarl +snash +snath +snaws +sneak +sneap +sneck +sneds +sneer +snell +snibs +snick +snide +sniff +snipe +snips +snits +snobs +snogs +snood +snook +snool +snoop +snoot +snore +snort +snots +snout +snows +snowy +snubs +snuck +snuff +snugs +snyes +soaks +soaps +soapy +soars +soave +sober +socko +socks +socle +sodas +soddy +sodic +sodom +sofar +sofas +softa +softs +softy +soggy +soils +sojas +sokes +sokol +solan +solar +soldi +soldo +soled +solei +soles +solid +solon +solos +solum +solus +solve +somas +sonar +sonde +sones +songs +sonic +sonly +sonny +sonsy +sooey +sooks +sooth +soots +sooty +sophs +sophy +sopor +soppy +soras +sorbs +sords +sorel +sorer +sores +sorgo +sorns +sorry +sorts +sorus +soths +sotol +sough +souks +souls +sound +soups +soupy +sours +souse +south +sowar +sowed +sower +soyas +soyuz +sozin +space +spacy +spade +spado +spaed +spaes +spahi +spail +spait +spake +spale +spall +spang +spank +spans +spare +spark +spars +spasm +spate +spats +spawn +spays +speak +spean +spear +speck +specs +speed +speel +speer +speil +speir +spell +spelt +spend +spent +sperm +spews +spica +spice +spick +spics +spicy +spied +spiel +spier +spies +spiff +spike +spiks +spiky +spile +spill +spilt +spine +spins +spiny +spire +spirt +spiry +spite +spits +spitz +spivs +splat +splay +split +spode +spoil +spoke +spoof +spook +spool +spoon +spoor +spore +sport +spots +spout +sprag +sprat +spray +spree +sprig +sprit +sprue +sprug +spuds +spued +spues +spume +spumy +spunk +spurn +spurs +spurt +sputa +squab +squad +squat +squaw +squeg +squib +squid +stabs +stack +stade +staff +stage +stags +stagy +staid +staig +stain +stair +stake +stale +stalk +stall +stamp +stand +stane +stang +stank +staph +stare +stark +stars +start +stash +state +stats +stave +stays +stead +steak +steal +steam +steed +steek +steel +steep +steer +stein +stela +stele +stems +steno +steps +stere +stern +stets +stews +stich +stick +stied +sties +stiff +stile +still +stilt +stime +stimy +sting +stink +stint +stipe +stirk +stirp +stirs +stoae +stoai +stoas +stoat +stobs +stock +stogy +stoic +stoke +stole +stoma +stomp +stone +stony +stood +stook +stool +stoop +stope +stops +stopt +store +stork +storm +story +stoss +stoup +stour +stout +stove +stowp +stows +strap +straw +stray +strep +strew +stria +strip +strop +strow +stroy +strum +strut +stubs +stuck +studs +study +stuff +stull +stump +stums +stung +stunk +stuns +stunt +stupa +stupe +sturt +styed +styes +style +styli +stymy +suave +subah +subas +suber +sucks +sucre +sudds +sudor +sudsy +suede +suers +suets +suety +sugar +sughs +suing +suint +suite +suits +sulci +sulfa +sulfo +sulks +sulky +sully +sulus +sumac +summa +sumos +sumps +sunna +sunns +sunny +sunup +super +supes +supra +surah +sural +suras +surds +surer +surfs +surfy +surge +surgy +surly +surra +sushi +sutra +sutta +swabs +swage +swags +swail +swain +swale +swami +swamp +swamy +swang +swank +swans +swaps +sward +sware +swarf +swarm +swart +swash +swath +swats +sways +swear +sweat +swede +sweep +sweer +sweet +swell +swept +swift +swigs +swill +swims +swine +swing +swink +swipe +swirl +swish +swiss +swith +swive +swobs +swoon +swoop +swops +sword +swore +sworn +swots +swoun +swung +sycee +syces +sykes +sylis +sylph +sylva +synch +syncs +synod +synth +syphs +syren +syrup +sysop +tabby +taber +tabes +tabid +tabla +table +taboo +tabor +tabun +tabus +taces +tacet +tache +tachs +tacit +tacks +tacky +tacos +tacts +taels +taffy +tafia +tahrs +taiga +tails +tains +taint +tajes +taken +taker +takes +takin +talar +talas +talcs +taler +tales +talks +talky +tally +talon +taluk +talus +tamal +tamed +tamer +tames +tamis +tammy +tamps +tango +tangs +tangy +tanka +tanks +tansy +tanto +tapas +taped +taper +tapes +tapir +tapis +tardo +tardy +tared +tares +targe +tarns +taroc +tarok +taros +tarot +tarps +tarre +tarry +tarsi +tarts +tarty +tasks +tasse +taste +tasty +tatar +tater +tates +tatty +taunt +taupe +tauts +tawed +tawer +tawie +tawny +tawse +taxed +taxer +taxes +taxis +taxon +taxus +tazza +tazze +teach +teaks +teals +teams +tears +teary +tease +teats +techy +tecta +teddy +teels +teems +teens +teeny +teeth +teffs +tegua +teiid +teind +telae +teles +telex +telia +telic +tells +telly +teloi +telos +tempi +tempo +temps +tempt +tench +tends +tenet +tenia +tenon +tenor +tense +tenth +tents +tenty +tepal +tepas +tepee +tepid +tepoy +terai +terce +terga +terms +terne +terns +terra +terry +terse +tesla +testa +tests +testy +teths +tetra +teuch +teugh +tewed +texas +texts +thack +thane +thank +tharm +thaws +thebe +theca +theft +thegn +thein +their +theme +thens +there +therm +these +theta +thews +thewy +thick +thief +thigh +thill +thine +thing +think +thins +thiol +third +thirl +thole +thong +thorn +thoro +thorp +those +thous +thraw +three +threw +thrip +throb +throe +throw +thrum +thuds +thugs +thuja +thumb +thump +thunk +thurl +thuya +thyme +thymi +thymy +tiara +tibia +tical +ticks +tidal +tided +tides +tiers +tiffs +tiger +tight +tigon +tikes +tikis +tilak +tilde +tiled +tiler +tiles +tills +tilth +tilts +timed +timer +times +timid +tinct +tinea +tined +tines +tinge +tings +tinny +tints +tipis +tippy +tipsy +tired +tires +tirls +tiros +titan +titer +tithe +titis +title +titre +titty +tizzy +toads +toady +toast +today +toddy +toffs +toffy +tofts +tofus +togae +togas +togue +toile +toils +toits +tokay +toked +token +toker +tokes +tolan +tolas +toled +toles +tolls +tolus +tolyl +toman +tombs +tomes +tommy +tonal +tondi +tondo +toned +toner +tones +toney +tonga +tongs +tonic +tonne +tonus +tools +toons +tooth +toots +topaz +toped +topee +toper +topes +tophe +tophi +tophs +topic +topis +topoi +topos +toque +torah +toras +torch +torcs +tores +toric +torii +toros +torot +torse +torsi +torsk +torso +torte +torts +torus +total +toted +totem +toter +totes +touch +tough +tours +touse +touts +towed +towel +tower +towie +towns +towny +toxic +toxin +toyed +toyer +toyon +toyos +trace +track +tract +trade +tragi +traik +trail +train +trait +tramp +trams +trank +tranq +trans +traps +trapt +trash +trass +trave +trawl +trays +tread +treat +treed +treen +trees +treks +trend +tress +trets +trews +treys +triac +triad +trial +tribe +trice +trick +tried +trier +tries +trigo +trigs +trike +trill +trims +trine +triol +trios +tripe +trips +trite +troak +trock +trode +trois +troke +troll +tromp +trona +trone +troop +trooz +trope +troth +trots +trout +trove +trows +troys +truce +truck +trued +truer +trues +trugs +trull +truly +trump +trunk +truss +trust +truth +tryma +tryst +tsade +tsadi +tsars +tsked +tsuba +tubae +tubal +tubas +tubby +tubed +tuber +tubes +tucks +tufas +tuffs +tufts +tufty +tules +tulip +tulle +tumid +tummy +tumor +tumps +tunas +tuned +tuner +tunes +tungs +tunic +tunny +tupik +tuque +turbo +turds +turfs +turfy +turks +turns +turps +tushy +tusks +tutee +tutor +tutti +tutty +tutus +tuxes +tuyer +twaes +twain +twang +twats +tweak +tweed +tween +tweet +twerp +twice +twier +twigs +twill +twine +twins +twiny +twirl +twirp +twist +twits +twixt +twyer +tyees +tyers +tying +tykes +tyned +tynes +typal +typed +types +typey +typic +typos +typps +tyred +tyres +tyros +tythe +tzars +udder +uhlan +ukase +ulama +ulans +ulcer +ulema +ulnad +ulnae +ulnar +ulnas +ulpan +ultra +ulvas +umbel +umber +umbos +umbra +umiac +umiak +umiaq +umped +unais +unapt +unarm +unary +unaus +unban +unbar +unbid +unbox +uncap +uncia +uncle +uncos +uncoy +uncus +uncut +undee +under +undid +undue +unfed +unfit +unfix +ungot +unhat +unhip +unify +union +unite +units +unity +unlay +unled +unlet +unlit +unman +unmet +unmew +unmix +unpeg +unpen +unpin +unrig +unrip +unsay +unset +unsew +unsex +untie +until +unwed +unwit +unwon +unzip +upbow +upbye +updos +updry +upend +uplit +upped +upper +upset +uraei +urare +urari +urase +urate +urban +urbia +ureal +ureas +uredo +ureic +urged +urger +urges +urial +urine +ursae +usage +users +usher +using +usnea +usque +usual +usurp +usury +uteri +utile +utter +uveal +uveas +uvula +vacua +vagal +vague +vagus +vails +vairs +vakil +vales +valet +valid +valor +valse +value +valve +vamps +vanda +vaned +vanes +vangs +vapid +vapor +varas +varia +varix +varna +varus +varve +vasal +vases +vasts +vasty +vatic +vatus +vault +vaunt +veals +vealy +veena +veeps +veers +veery +vegan +vegie +veils +veins +veiny +velar +velds +veldt +velum +venae +venal +vends +venge +venin +venom +vents +venue +verbs +verge +verse +verso +verst +verts +vertu +verve +vesta +vests +vetch +vexed +vexer +vexes +vexil +vials +viand +vibes +vicar +viced +vices +vichy +video +viers +views +viewy +vigas +vigil +vigor +viler +villa +villi +vills +vimen +vinal +vinas +vinca +vined +vines +vinic +vinos +vinyl +viola +viols +viper +viral +vireo +vires +virga +virid +virls +virtu +virus +visas +vised +vises +visit +visor +vista +vitae +vital +vitta +vivas +vivid +vixen +vizir +vizor +vocal +voces +vodka +vodun +vogie +vogue +voice +voids +voila +voile +volar +voled +voles +volta +volte +volti +volts +volva +vomer +vomit +voted +voter +votes +vouch +vowed +vowel +vower +vroom +vrouw +vrows +vuggs +vuggy +vughs +vulgo +vulva +vying +wacke +wacko +wacks +wacky +waddy +waded +wader +wades +wadis +wafer +waffs +wafts +waged +wager +wages +wagon +wahoo +waifs +wails +wains +wairs +waist +waits +waive +waked +waken +waker +wakes +waled +waler +wales +walks +walla +walls +wally +waltz +wames +wamus +wands +waned +wanes +waney +wanly +wants +wards +wared +wares +warks +warms +warns +warps +warts +warty +washy +wasps +waspy +waste +wasts +watap +watch +water +watts +waugh +wauks +wauls +waved +waver +waves +wavey +wawls +waxed +waxen +waxer +waxes +weald +weals +weans +wears +weary +weave +webby +weber +wecht +wedel +wedge +wedgy +weeds +weedy +weeks +weens +weeny +weeps +weepy +weest +weets +wefts +weigh +weird +weirs +wekas +welch +welds +wells +welly +welsh +welts +wench +wends +wenny +wests +wetly +whack +whale +whamo +whams +whang +whaps +wharf +whats +whaup +wheal +wheat +wheel +wheen +wheep +whelk +whelm +whelp +whens +where +whets +whews +wheys +which +whids +whiff +whigs +while +whims +whine +whins +whiny +whips +whipt +whirl +whirr +whirs +whish +whisk +whist +white +whits +whity +whizz +whole +whomp +whoof +whoop +whops +whore +whorl +whort +whose +whoso +whump +wicks +widdy +widen +wider +wides +widow +width +wield +wifed +wifes +wifty +wigan +wiggy +wight +wilco +wilds +wiled +wiles +wills +willy +wilts +wimps +wimpy +wince +winch +winds +windy +wined +wines +winey +wings +wingy +winks +winos +winze +wiped +wiper +wipes +wired +wirer +wires +wirra +wised +wiser +wises +wisha +wisps +wispy +wists +witan +witch +wited +wites +withe +withy +witty +wived +wiver +wives +wizen +wizes +woads +woald +wodge +woful +woken +wolds +wolfs +woman +wombs +womby +women +wonks +wonky +wonts +woods +woody +wooed +wooer +woofs +wools +wooly +woops +woosh +woozy +words +wordy +works +world +worms +wormy +worry +worse +worst +worth +worts +would +wound +woven +wowed +wrack +wrang +wraps +wrapt +wrath +wreak +wreck +wrens +wrest +wrick +wried +wrier +wries +wring +wrist +write +writs +wrong +wrote +wroth +wrung +wryer +wryly +wurst +wussy +wyled +wyles +wynds +wynns +wyted +wytes +xebec +xenia +xenic +xenon +xeric +xerox +xerus +xylan +xylem +xylol +xylyl +xysti +xysts +yacht +yacks +yaffs +yager +yagis +yahoo +yaird +yamen +yamun +yangs +yanks +yapok +yapon +yards +yarer +yarns +yauds +yauld +yaups +yawed +yawls +yawns +yawps +yeans +yearn +years +yeast +yecch +yechs +yechy +yeggs +yelks +yells +yelps +yenta +yente +yerba +yerks +yeses +yetis +yetts +yeuks +yeuky +yield +yikes +yills +yince +yipes +yirds +yirrs +yirth +ylems +yobbo +yocks +yodel +yodhs +yodle +yogas +yogee +yoghs +yogic +yogin +yogis +yoked +yokel +yokes +yolks +yolky +yomim +yonic +yonis +yores +young +yourn +yours +youse +youth +yowed +yowes +yowie +yowls +yuans +yucas +yucca +yucch +yucks +yucky +yugas +yulan +yules +yummy +yupon +yurta +yurts +zaire +zamia +zanza +zappy +zarfs +zaxes +zayin +zazen +zeals +zebec +zebra +zebus +zeins +zerks +zeros +zests +zesty +zetas +zibet +zilch +zills +zincs +zincy +zineb +zings +zingy +zinky +zippy +ziram +zitis +zizit +zlote +zloty +zoeae +zoeal +zoeas +zombi +zonal +zoned +zoner +zones +zonks +zooid +zooks +zooms +zoons +zooty +zoril +zoris +zowie +zymes diff --git a/apps/word-guess/icon.svg b/apps/word-guess/icon.svg new file mode 100644 index 0000000..ecc7717 --- /dev/null +++ b/apps/word-guess/icon.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/word-guess/shots/end.png b/apps/word-guess/shots/end.png new file mode 100644 index 0000000..ec80786 Binary files /dev/null and b/apps/word-guess/shots/end.png differ diff --git a/apps/word-guess/shots/menu.png b/apps/word-guess/shots/menu.png new file mode 100644 index 0000000..619aeb2 Binary files /dev/null and b/apps/word-guess/shots/menu.png differ diff --git a/apps/word-guess/shots/playing.png b/apps/word-guess/shots/playing.png new file mode 100644 index 0000000..3dcb78e Binary files /dev/null and b/apps/word-guess/shots/playing.png differ diff --git a/apps/word-guess/src/game.rs b/apps/word-guess/src/game.rs new file mode 100644 index 0000000..1a7dc8e --- /dev/null +++ b/apps/word-guess/src/game.rs @@ -0,0 +1,640 @@ +//! The rules, the statistics, the calendar and the save blob: no `Api` here, so `wp2 test` covers all of it. + +use crate::words::{self, LEN, Word}; + +pub const ROWS: usize = 6; + +/// What a guess tells about one letter. Ordered: a better mark replaces a worse one on the keyboard. +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default)] +pub enum Mark { + /// Not guessed yet. + #[default] + Unknown, + /// Not in the word (or every copy of it is already accounted for). + Absent, + /// In the word, in another place. + Present, + /// In the word, in this place. + Correct, +} + +/// Marks `guess` against `answer`. Repeated letters count: a guessed letter is marked only as often as the answer +/// has it, places that match first, then from left to right. +pub fn score(guess: &Word, answer: &Word) -> [Mark; LEN] { + let mut marks = [Mark::Absent; LEN]; + // copies of each letter in the answer not matched in place + let mut left = [0u8; 27]; + for i in 0..LEN { + if guess[i] == answer[i] { + marks[i] = Mark::Correct; + } else { + left[answer[i] as usize % 27] += 1; + } + } + for i in 0..LEN { + let l = guess[i] as usize % 27; + if marks[i] != Mark::Correct && left[l] > 0 { + marks[i] = Mark::Present; + left[l] -= 1; + } + } + marks +} + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum State { + Playing, + Won, + Lost, +} + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum Submit { + /// Fewer than five letters. + Short, + /// Not in the word list. + Unknown, + /// Counted: the row is the next one on the board. + Done, +} + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Game { + /// Index into the answers. + pub answer: u16, + pub rows: [Word; ROWS], + /// Rows guessed. + pub n: u8, + /// The row being typed: `len` letters. + pub cur: Word, + pub len: u8, +} + +impl Game { + pub const fn new(answer: u16) -> Game { + Game { answer, rows: [[0; LEN]; ROWS], n: 0, cur: [0; LEN], len: 0 } + } + + pub fn word(&self) -> Word { + words::answer(self.answer as usize) + } + + pub fn state(&self) -> State { + let n = self.n as usize; + if n > 0 && self.rows[n - 1] == self.word() { + State::Won + } else if n >= ROWS { + State::Lost + } else { + State::Playing + } + } + + pub fn over(&self) -> bool { + self.state() != State::Playing + } + + pub fn marks(&self, row: usize) -> [Mark; LEN] { + if row < self.n as usize { score(&self.rows[row], &self.word()) } else { [Mark::Unknown; LEN] } + } + + /// Adds a letter `1..=26` to the row being typed; false if it is full or the game is over. + pub fn letter(&mut self, l: u8) -> bool { + if self.over() || self.len as usize >= LEN || !(1..=26).contains(&l) { + return false; + } + self.cur[self.len as usize] = l; + self.len += 1; + true + } + + /// Takes the last typed letter off; false if there is none. + pub fn back(&mut self) -> bool { + if self.over() || self.len == 0 { + return false; + } + self.len -= 1; + self.cur[self.len as usize] = 0; + true + } + + pub fn submit(&mut self) -> Submit { + if self.over() || (self.len as usize) < LEN { + return Submit::Short; + } + if !words::is_word(&self.cur) { + return Submit::Unknown; + } + self.rows[self.n as usize] = self.cur; + self.n += 1; + self.cur = [0; LEN]; + self.len = 0; + Submit::Done + } + + /// What the guesses so far tell about each letter, indexed by letter (`[0]` unused): the best mark it got. + pub fn hints(&self) -> [Mark; 27] { + self.hints_rows(self.n as usize) + } + + /// [`Game::hints`] from the first `rows` guesses only (while the last one is being revealed). + pub fn hints_rows(&self, rows: usize) -> [Mark; 27] { + let mut h = [Mark::Unknown; 27]; + for r in 0..rows.min(self.n as usize) { + let m = self.marks(r); + for i in 0..LEN { + let l = self.rows[r][i] as usize % 27; + h[l] = h[l].max(m[i]); + } + } + h + } + + pub const BYTES: usize = 2 + 1 + LEN * ROWS + 1 + LEN; + + pub fn encode(&self, out: &mut [u8]) { + out[..2].copy_from_slice(&self.answer.to_le_bytes()); + out[2] = self.n; + for (r, row) in self.rows.iter().enumerate() { + out[3 + r * LEN..3 + (r + 1) * LEN].copy_from_slice(row); + } + out[3 + LEN * ROWS] = self.len; + out[4 + LEN * ROWS..Self::BYTES].copy_from_slice(&self.cur); + } + + /// `None` for anything a game can't be: an answer past the list, letters out of range, rows after the end. + pub fn decode(b: &[u8]) -> Option { + if b.len() < Self::BYTES { + return None; + } + let answer = u16::from_le_bytes([b[0], b[1]]); + let n = b[2]; + let len = b[3 + LEN * ROWS]; + if answer as usize >= words::ANSWER_COUNT || n as usize > ROWS || len as usize > LEN { + return None; + } + let mut g = Game::new(answer); + let letter = |v: u8, used: bool| if used { (1..=26).contains(&v) } else { v == 0 }; + for r in 0..ROWS { + for i in 0..LEN { + let v = b[3 + r * LEN + i]; + if !letter(v, r < n as usize) { + return None; + } + g.rows[r][i] = v; + } + } + for i in 0..LEN { + let v = b[4 + LEN * ROWS + i]; + if !letter(v, i < len as usize) { + return None; + } + g.cur[i] = v; + } + g.n = n; + g.len = len; + // the word was found before the last row: nothing may follow it + if (0..n.saturating_sub(1) as usize).any(|r| g.rows[r] == g.word()) { + return None; + } + if g.over() && len > 0 { + return None; + } + Some(g) + } +} + +/// Games of one kind: daily, or practice. +#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)] +pub struct Stats { + pub played: u16, + pub wins: u16, + /// Daily: wins on consecutive days up to `last_win`. Practice: consecutive wins. + pub streak: u16, + pub best: u16, + /// Daily: the day of the last win (`NO_DAY`: none). + pub last_win: i32, + /// Wins by the number of guesses they took. + pub dist: [u16; ROWS], +} + +pub const NO_DAY: i32 = i32::MIN; + +impl Stats { + pub const fn new() -> Stats { + Stats { played: 0, wins: 0, streak: 0, best: 0, last_win: NO_DAY, dist: [0; ROWS] } + } + + /// Counts a finished game: `day` for a daily one (its streak needs the days to follow each other). + pub fn record(&mut self, g: &Game, day: Option) { + let won = g.state() == State::Won; + self.played = self.played.saturating_add(1); + if won { + self.wins = self.wins.saturating_add(1); + let i = (g.n as usize).clamp(1, ROWS) - 1; + self.dist[i] = self.dist[i].saturating_add(1); + self.streak = match day { + Some(d) if self.last_win != NO_DAY && self.last_win == d - 1 => self.streak.saturating_add(1), + Some(_) => 1, + None => self.streak.saturating_add(1), + }; + if let Some(d) = day { + self.last_win = d; + } + self.best = self.best.max(self.streak); + } else { + self.streak = 0; + } + } + + /// The streak as of `today`: a daily streak ends when a day goes by without a win. + pub fn current(&self, today: Option) -> u16 { + match today { + Some(t) if self.last_win == NO_DAY || self.last_win < t - 1 => 0, + _ => self.streak, + } + } + + /// Wins as a whole percentage of the games played. + pub fn win_pct(&self) -> u32 { + if self.played == 0 { 0 } else { (self.wins as u32 * 100 + self.played as u32 / 2) / self.played as u32 } + } + + pub const BYTES: usize = 2 * 4 + 4 + 2 * ROWS; + + fn encode(&self, out: &mut [u8]) { + for (i, v) in [self.played, self.wins, self.streak, self.best].into_iter().enumerate() { + out[2 * i..2 * i + 2].copy_from_slice(&v.to_le_bytes()); + } + out[8..12].copy_from_slice(&self.last_win.to_le_bytes()); + for (i, v) in self.dist.iter().enumerate() { + out[12 + 2 * i..14 + 2 * i].copy_from_slice(&v.to_le_bytes()); + } + } + + fn decode(b: &[u8]) -> Stats { + let u = |i: usize| u16::from_le_bytes([b[i], b[i + 1]]); + let mut s = Stats { + played: u(0), + wins: u(2), + streak: u(4), + best: u(6), + last_win: i32::from_le_bytes([b[8], b[9], b[10], b[11]]), + dist: [0; ROWS], + }; + for i in 0..ROWS { + s.dist[i] = u(12 + 2 * i); + } + s + } +} + +/// Everything kept in storage. +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub struct Save { + /// A short buzz on every key. + pub ticks: bool, + pub daily: Stats, + pub practice: Stats, + /// The daily game of `day`, finished or not. + pub day: i32, + pub today: Option, + /// The practice game, if one was left unfinished. + pub open: Option, +} + +const MAGIC: [u8; 2] = *b"WG"; +const VERSION: u8 = 1; +pub const BLOB: usize = 4 + 2 * Stats::BYTES + 4 + 2 * (1 + Game::BYTES); + +impl Save { + pub const fn new() -> Save { + Save { ticks: true, daily: Stats::new(), practice: Stats::new(), day: NO_DAY, today: None, open: None } + } + + pub fn encode(&self) -> [u8; BLOB] { + let mut b = [0u8; BLOB]; + b[..2].copy_from_slice(&MAGIC); + b[2] = VERSION; + b[3] = self.ticks as u8; + let mut at = 4; + self.daily.encode(&mut b[at..]); + at += Stats::BYTES; + self.practice.encode(&mut b[at..]); + at += Stats::BYTES; + b[at..at + 4].copy_from_slice(&self.day.to_le_bytes()); + at += 4; + for g in [self.today, self.open] { + if let Some(g) = g { + b[at] = 1; + g.encode(&mut b[at + 1..]); + } + at += 1 + Game::BYTES; + } + b + } + + /// A blob from another app, another version or a broken one loads as `None`: the caller starts afresh. + pub fn decode(b: &[u8]) -> Option { + if b.len() < BLOB || b[..2] != MAGIC || b[2] != VERSION || b[3] > 1 { + return None; + } + let mut s = Save::new(); + s.ticks = b[3] == 1; + let mut at = 4; + s.daily = Stats::decode(&b[at..]); + at += Stats::BYTES; + s.practice = Stats::decode(&b[at..]); + at += Stats::BYTES; + s.day = i32::from_le_bytes([b[at], b[at + 1], b[at + 2], b[at + 3]]); + at += 4; + let mut games = [None; 2]; + for g in games.iter_mut() { + *g = match b[at] { + 0 => None, + 1 => Some(Game::decode(&b[at + 1..])?), + _ => return None, + }; + at += 1 + Game::BYTES; + } + s.today = games[0]; + s.open = games[1]; + // a daily game whose word is not that day's (the list changed in an update): dropped + if s.today.is_some_and(|g| s.day == NO_DAY || g.answer as usize != words::daily(s.day)) { + s.today = None; + } + Some(s) + } +} + +/// Days since 1970-01-01 of a civil date (H. Hinnant's `days_from_civil`). +pub fn days_from_civil(y: i32, m: u32, d: u32) -> i32 { + let y = if m <= 2 { y - 1 } else { y }; + let era = if y >= 0 { y } else { y - 399 } / 400; + let yoe = y - era * 400; + let mp = (m as i32 + 9) % 12; + let doy = (153 * mp + 2) / 5 + d as i32 - 1; + let doe = yoe * 365 + yoe / 4 - yoe / 100 + doy; + era * 146_097 + doe - 719_468 +} + +/// The daily word's day number: days from 2026-12-01 to the local date. +pub fn day_number(y: i32, m: u32, d: u32) -> i32 { + days_from_civil(y, m, d) - days_from_civil(2026, 12, 1) +} + +/// Hours and minutes to the next local midnight, from `hour:minute` (rounded up to the minute). +pub fn until_midnight(hour: u32, minute: u32) -> (u32, u32) { + let left = (24 * 60 - (hour * 60 + minute).min(24 * 60 - 1)).min(24 * 60 - 1); + (left / 60, left % 60) +} + +/// Picks a practice word: never the one just played or today's. +pub fn practice_word(seed: u32, not: &[usize]) -> u16 { + let mut x = seed | 1; + loop { + // xorshift32 + x ^= x << 13; + x ^= x >> 17; + x ^= x << 5; + let i = (x as usize) % words::ANSWER_COUNT; + if !not.contains(&i) { + return i as u16; + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::words::word; + use Mark::{Absent as A, Correct as C, Present as P}; + + fn marks(guess: &str, answer: &str) -> [Mark; LEN] { + score(&word(guess), &word(answer)) + } + + fn game_for(answer: &str) -> Game { + let w = word(answer); + let i = (0..words::ANSWER_COUNT).find(|&i| words::answer(i) == w).expect("an answer"); + Game::new(i as u16) + } + + fn typed(g: &mut Game, s: &str) -> Submit { + for c in s.bytes() { + g.letter(c - b'a' + 1); + } + g.submit() + } + + #[test] + fn plain_scoring() { + assert_eq!(marks("crane", "crane"), [C; 5]); + assert_eq!(marks("ghost", "crane"), [A; 5]); + assert_eq!(marks("nacre", "crane"), [P, P, P, P, C]); + assert_eq!(marks("trace", "crane"), [A, C, C, P, C]); + } + + #[test] + fn repeated_letters_are_marked_once_per_copy() { + // one E in the answer, two guessed: only the first is marked + assert_eq!(marks("speed", "abide"), [A, A, P, A, P]); + // two Es in the answer, three guessed: the two in place, the third not + assert_eq!(marks("eerie", "speed"), [P, P, A, A, A]); + assert_eq!(marks("geese", "speed"), [A, P, C, P, A]); + // the in-place copies win over an earlier misplaced one + assert_eq!(marks("lolly", "hello"), [A, P, C, C, A]); + assert_eq!(marks("allee", "eagle"), [P, P, A, P, C]); + // misplaced copies are marked left to right + assert_eq!(marks("ooxxx", "xxxxo"), [P, A, C, C, P]); + assert_eq!(marks("abbey", "babes"), [P, P, C, C, A]); + assert_eq!(marks("kayak", "kebab"), [C, A, A, C, A]); + } + + #[test] + fn typing_and_submitting() { + let mut g = game_for("crane"); + assert_eq!(g.submit(), Submit::Short); + assert!(!g.back()); + assert_eq!(typed(&mut g, "cra"), Submit::Short); + assert!(g.back()); + assert_eq!(g.len, 2); + for _ in 0..5 { + g.back(); + } + assert_eq!(typed(&mut g, "xqzvb"), Submit::Unknown); + assert_eq!(g.n, 0); + assert_eq!(g.len, 5); + assert!(!g.letter(1), "a full row takes no more letters"); + for _ in 0..5 { + g.back(); + } + assert_eq!(typed(&mut g, "trace"), Submit::Done); + assert_eq!((g.n, g.len, g.state()), (1, 0, State::Playing)); + assert_eq!(typed(&mut g, "crane"), Submit::Done); + assert_eq!(g.state(), State::Won); + assert!(!g.letter(1)); + assert_eq!(g.submit(), Submit::Short); + } + + #[test] + fn six_misses_lose() { + let mut g = game_for("crane"); + for w in ["ghost", "plumb", "dizzy", "fjord", "whisk", "vouch"] { + assert_eq!(typed(&mut g, w), Submit::Done, "{w}"); + } + assert_eq!(g.state(), State::Lost); + let mut g = game_for("crane"); + for w in ["ghost", "plumb", "dizzy", "fjord", "whisk", "crane"] { + typed(&mut g, w); + } + assert_eq!(g.state(), State::Won); + } + + #[test] + fn keyboard_hints_keep_the_best_mark() { + let mut g = game_for("crane"); + typed(&mut g, "nacre"); // N A C R present, E correct + typed(&mut g, "trace"); // T absent, R A correct + let h = g.hints(); + let at = |c: u8| h[(c - b'a' + 1) as usize]; + assert_eq!(at(b'n'), Mark::Present); + assert_eq!(at(b'r'), Mark::Correct); + assert_eq!(at(b'a'), Mark::Correct); + assert_eq!(at(b'c'), Mark::Present); + assert_eq!(at(b'e'), Mark::Correct); + assert_eq!(at(b't'), Mark::Absent); + assert_eq!(at(b'z'), Mark::Unknown); + // a letter marked absent as a surplus copy keeps its better mark + let mut g = game_for("abide"); + typed(&mut g, "speed"); + let h = g.hints(); + assert_eq!(h[5], Mark::Present); // e: placed wrong, the second copy absent + assert_eq!(h[19], Mark::Absent); // s + } + + #[test] + fn stats_count_streaks_by_day() { + let mut won = game_for("crane"); + typed(&mut won, "trace"); + typed(&mut won, "crane"); + let mut lost = game_for("crane"); + for w in ["ghost", "plumb", "dizzy", "fjord", "whisk", "vouch"] { + typed(&mut lost, w); + } + let mut s = Stats::new(); + assert_eq!(s.current(Some(0)), 0); + s.record(&won, Some(10)); + s.record(&won, Some(11)); + s.record(&won, Some(12)); + assert_eq!((s.played, s.wins, s.streak, s.best), (3, 3, 3, 3)); + assert_eq!(s.dist, [0, 3, 0, 0, 0, 0]); + assert_eq!(s.current(Some(12)), 3); + assert_eq!(s.current(Some(13)), 3, "today not played yet"); + assert_eq!(s.current(Some(14)), 0, "a day went by"); + s.record(&won, Some(14)); // after a gap: a new streak + assert_eq!((s.streak, s.best), (1, 3)); + s.record(&lost, Some(15)); + assert_eq!((s.played, s.wins, s.streak, s.best), (5, 4, 0, 3)); + assert_eq!(s.win_pct(), 80); + let mut p = Stats::new(); + p.record(&won, None); + p.record(&won, None); + assert_eq!(p.streak, 2); + assert_eq!(p.current(None), 2); + assert_eq!(Stats::new().win_pct(), 0); + } + + #[test] + fn save_round_trips() { + let mut s = Save::new(); + s.ticks = false; + s.daily.played = 7; + s.daily.last_win = 3; + s.daily.dist = [1, 2, 3, 4, 5, 6]; + s.practice.wins = 65535; + s.day = 42; + let mut g = Game::new(words::daily(42) as u16); + g.letter(3); + g.letter(18); + s.today = Some(g); + let mut p = game_for("crane"); + typed(&mut p, "trace"); + typed(&mut p, "cr"); + s.open = Some(p); + let b = s.encode(); + assert!(b.len() <= 4096); + assert_eq!(Save::decode(&b), Some(s)); + assert_eq!(Save::decode(&Save::new().encode()), Some(Save::new())); + } + + #[test] + fn bad_blobs_load_as_none() { + let good = { + let mut s = Save::new(); + s.day = 5; + s.today = Some(Game::new(words::daily(5) as u16)); + s.encode() + }; + assert!(Save::decode(&good).is_some()); + assert_eq!(Save::decode(&[]), None); + assert_eq!(Save::decode(&good[..BLOB - 1]), None); + assert_eq!(Save::decode(&[0xFF; BLOB]), None); + let bad = |at: usize, v: u8| { + let mut b = good; + b[at] = v; + Save::decode(&b) + }; + assert_eq!(bad(0, b'X'), None, "magic"); + assert_eq!(bad(2, 2), None, "version"); + assert_eq!(bad(3, 7), None, "flags"); + let g = 4 + 2 * Stats::BYTES + 4; // the daily game's present byte + assert_eq!(bad(g, 2), None); + assert_eq!(bad(g + 2, 0xFF), None, "answer index"); + assert_eq!(bad(g + 3, 7), None, "rows"); + assert_eq!(bad(g + 4, 30), None, "a letter in an unguessed row"); + assert_eq!(bad(g + 4 + LEN * ROWS, 9), None, "typed length"); + // a daily game that is not that day's word is dropped, the rest kept + let mut s = Save::decode(&good).unwrap(); + s.day = 6; + assert_eq!(Save::decode(&s.encode()).unwrap().today, None); + } + + #[test] + fn games_after_a_win_are_refused() { + let mut g = game_for("crane"); + typed(&mut g, "crane"); + let mut b = [0u8; Game::BYTES]; + g.encode(&mut b); + assert_eq!(Game::decode(&b), Some(g)); + // a row after the winning one + b[2] = 2; + b[3 + LEN..3 + 2 * LEN].copy_from_slice(&word("trace")); + assert_eq!(Game::decode(&b), None); + } + + #[test] + fn calendar() { + assert_eq!(days_from_civil(1970, 1, 1), 0); + assert_eq!(days_from_civil(2000, 3, 1), 11_017); + assert_eq!(day_number(2026, 12, 1), 0); + assert_eq!(day_number(2026, 12, 2), 1); + assert_eq!(day_number(2026, 11, 30), -1); + assert_eq!(day_number(2027, 1, 1), 31); + assert_eq!(day_number(2028, 3, 1) - day_number(2028, 2, 28), 2, "leap day"); + assert_eq!(until_midnight(0, 0), (23, 59)); + assert_eq!(until_midnight(23, 59), (0, 1)); + assert_eq!(until_midnight(18, 30), (5, 30)); + assert_eq!(until_midnight(12, 0), (12, 0)); + } + + #[test] + fn practice_words_skip_the_given_ones() { + let today = words::daily(1); + for seed in 0..500u32 { + let i = practice_word(seed.wrapping_mul(2_654_435_761), &[today, 7]) as usize; + assert!(i < words::ANSWER_COUNT && i != today && i != 7); + } + assert_ne!(practice_word(1, &[]), practice_word(2, &[])); + } +} diff --git a/apps/word-guess/src/main.rs b/apps/word-guess/src/main.rs new file mode 100644 index 0000000..a4f9401 --- /dev/null +++ b/apps/word-guess/src/main.rs @@ -0,0 +1,487 @@ +//! Word Guess: find the hidden five-letter word in six tries. Each guess marks its letters: right place, in the word +//! elsewhere, or not in the word. +//! +//! - Daily: one word per local date, the same for everyone (`words::daily`); one game a day, resumed if you leave. +//! - Practice: as many random words as you like, counted apart from the daily streak. +//! - Statistics, How to play (with the key tick setting). +//! +//! Canvas drawing (`view.rs`), rules and storage in `game.rs`, the word lists in `words.rs`. Taps act on the finger's +//! lift at the place it went down (TOUCH_UP's x/y are unreliable on the watch); BUTTON saves and exits. +#![cfg_attr(any(target_os = "none", wp2_sim), no_main, cfg_attr(target_os = "none", no_std))] + +#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] +mod game; +#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] +mod view; +#[cfg_attr(not(any(target_os = "none", wp2_sim)), allow(dead_code))] +mod words; + +#[cfg(not(any(target_os = "none", wp2_sim)))] +fn main() {} + +#[cfg(any(target_os = "none", wp2_sim))] +mod device { + use crate::game::{self, BLOB, Game, NO_DAY, Save, State, Submit}; + use crate::view::{self, Buf, EndHit, Key, MenuHit}; + use crate::words::{self, LEN}; + use cmf_wp2_app::{Api, BUTTON, CROWN, PAUSE, RESUME, TOUCH_DOWN, TOUCH_UP}; + use cmf_wp2_ui::haptic::{Motor, Pattern, TICK}; + + cmf_wp2_app::entry!(main); + cmf_wp2_app::app_icon!(); + + /// Longest press that still counts as a tap. + const TAP_MS: u32 = 600; + /// A guessed row turns over one tile at a time. + const REVEAL_MS: u32 = 110; + /// The refused row shakes: one offset per frame. + const SHAKE: [i32; 8] = [-8, 8, -6, 6, -4, 4, -2, 0]; + const SHAKE_MS: u32 = 35; + const TOAST_MS: u32 = 1300; + /// The finished board stays up this long before the results (a tap skips it). + const SHOWN_MS: u32 = 2400; + /// The countdown and the date are looked at this often on the screens that show them. + const CLOCK_MS: u32 = 20_000; + + const WIN: Pattern = Pattern::new(&[(600, 60), (0, 70), (600, 60), (0, 70), (900, 150), (0, 0)]); + const LOSS: Pattern = Pattern::new(&[(800, 240), (0, 0)]); + const NOPE: Pattern = Pattern::new(&[(550, 35), (0, 0)]); + + #[derive(Clone, Copy, PartialEq)] + enum Mode { + Menu, + Play, + /// The finished board, before the results. + Shown, + End, + Stats, + Help, + } + + fn due(now: u32, at: u32) -> bool { + (now.wrapping_sub(at) as i32) >= 0 + } + + fn left(now: u32, at: u32) -> u32 { + (at.wrapping_sub(now) as i32).max(0) as u32 + } + + struct App { + api: &'static Api, + motor: Motor, + sv: Save, + saved: Save, + g: Game, + /// `g` is today's game (else a practice one). + daily: bool, + mode: Mode, + /// The row being revealed and when it started. + reveal: Option<(usize, u32)>, + shown_tiles: usize, + shake: Option, + /// A message over the board and when it goes. + toast: Option<(&'static str, u32)>, + shown_until: u32, + /// What the clock-dependent screen showed: (day, minute of the day). + clock: (i32, u32), + } + + impl App { + /// Today's day number (days since 2026-12-01), from the watch's local date. + fn today(&self) -> Option { + self.api.time().map(|t| game::day_number(t.year as i32, t.month as u32, t.day as u32)) + } + + fn clock_key(&self) -> (i32, u32) { + self.api.time().map_or((0, 0), |t| (self.today().unwrap_or(0), t.hour as u32 * 60 + t.minute as u32)) + } + + /// Writes the blob when it changed: called at every point the app could be ended after. + fn save(&mut self) { + if self.sv != self.saved { + self.api.save(&self.sv.encode()); + self.saved = self.sv; + } + } + + /// Puts the game back where it is kept. + fn keep(&mut self) { + if self.daily { + self.sv.today = Some(self.g); + } else if !self.g.over() { + self.sv.open = Some(self.g); + } + } + + fn draw(&mut self) { + let mut s = self.api; + match self.mode { + Mode::Menu => { + let today = self.today(); + let mut d = Buf::new(); + match self.sv.today.filter(|_| Some(self.sv.day) == today) { + None => d.s("Play"), + Some(g) => match g.state() { + State::Won => d.s("Solved ").n(g.n as u32).s("/6"), + State::Lost => d.s("Missed"), + State::Playing if g.n == 0 && g.len == 0 => d.s("Play"), + State::Playing => d.n(g.n as u32).s(" of 6"), + }, + }; + let p = if self.sv.open.is_some_and(|g| g.n > 0 || g.len > 0) { "Resume" } else { "" }; + view::menu(&mut s, d.str(), p, self.sv.daily.current(today), self.sv.daily.best); + self.clock = self.clock_key(); + } + Mode::Play | Mode::Shown => { + let reveal = self.reveal.map(|(r, _)| (r, self.shown_tiles)); + view::game(&mut s, &self.g, reveal); + if self.mode == Mode::Shown { + self.end_toast(); + } + } + Mode::End => { + let today = self.today(); + let mut b = Buf::new(); + let st = if self.daily { + view::countdown(&mut b, self.api.time().map(|t| game::until_midnight(t.hour as u32, t.minute as u32))); + self.sv.daily + } else { + let p = self.sv.practice; + b.s("Practice ").n(p.wins as u32).s(" of ").n(p.played as u32); + p + }; + let today = if self.daily { today } else { None }; + view::end(&mut s, &self.g, &st, today, b.str(), self.daily); + self.clock = self.clock_key(); + } + Mode::Stats => view::stats(&mut s, &self.sv.daily, &self.sv.practice, self.today()), + Mode::Help => view::help(&mut s, self.sv.ticks), + } + self.api.show(); + } + + fn end_toast(&mut self) { + let mut s = self.api; + if self.g.state() == State::Won { + view::end_toast(&mut s, if self.g.n == 1 { "First try!" } else { "Got it!" }); + } else { + let w = self.g.word(); + let mut t = [0u8; LEN]; + for (i, &l) in w.iter().enumerate() { + t[i] = words::capital(l) as u8; + } + view::end_toast(&mut s, core::str::from_utf8(&t).unwrap_or("?")); + } + } + + fn tick(&mut self) { + if self.sv.ticks { + self.motor.play(TICK); + } + } + + fn start_daily(&mut self) { + let today = self.today().unwrap_or(if self.sv.day == NO_DAY { 0 } else { self.sv.day }); + let g = match self.sv.today { + Some(g) if self.sv.day == today => g, + _ => Game::new(words::daily(today) as u16), + }; + self.sv.day = today; + self.sv.today = Some(g); + self.g = g; + self.daily = true; + self.save(); + self.mode = if g.over() { Mode::End } else { Mode::Play }; + } + + fn start_practice(&mut self) { + let g = match self.sv.open { + Some(g) if !g.over() => g, + _ => { + let t = self.api.time().map_or(0, |t| (t.minute as u32 * 60 + t.second as u32) * 1000 + t.millis as u32); + let seed = self.api.now().wrapping_mul(2_654_435_761) ^ t; + let today = words::daily(self.today().unwrap_or(0)); + let last = if self.daily { today } else { self.g.answer as usize }; + Game::new(game::practice_word(seed, &[today, last])) + } + }; + self.sv.open = Some(g); + self.g = g; + self.daily = false; + self.save(); + self.mode = Mode::Play; + } + + /// Ends the animations at once (a pause, or before the screen is left). + fn settle(&mut self) { + if self.reveal.is_some() { + self.reveal = None; + self.revealed(); + } + self.shake = None; + self.toast = None; + } + + /// A guessed row is fully turned over: the keyboard learns from it; the game may be over. + fn revealed(&mut self) { + if self.g.over() { + let won = self.g.state() == State::Won; + if self.daily { + self.sv.daily.record(&self.g, Some(self.sv.day)); + } else { + self.sv.practice.record(&self.g, None); + self.sv.open = None; + } + self.motor.play(if won { WIN } else { LOSS }); + self.mode = Mode::Shown; + self.shown_until = self.api.now().wrapping_add(SHOWN_MS); + } + self.keep(); + self.save(); + } + + fn key(&mut self, k: Key) { + let mut s = self.api; + let hints = self.g.hints(); + match k { + Key::Letter(l) => { + let col = self.g.len as usize; + if self.g.letter(l) { + self.tick(); + view::tile(&mut s, self.g.n as usize, col, l, game::Mark::Unknown, 0); + if self.g.len as usize == LEN { + view::key(&mut s, Key::Enter, &hints, true); + } + self.keep(); + } + } + Key::Del => { + let was = self.g.len as usize; + if self.g.back() { + self.tick(); + view::tile(&mut s, self.g.n as usize, was - 1, 0, game::Mark::Unknown, 0); + if was == LEN { + view::key(&mut s, Key::Enter, &hints, false); + } + self.keep(); + } + } + Key::Enter => match self.g.submit() { + Submit::Done => { + self.tick(); + let row = self.g.n as usize - 1; + self.reveal = Some((row, self.api.now())); + self.shown_tiles = 0; + view::key(&mut s, Key::Enter, &hints, false); + self.keep(); + self.save(); // a guess counts: keep it even if the app is ended now + } + r => { + self.motor.play(NOPE); + let now = self.api.now(); + let text = if r == Submit::Unknown { "Not in word list" } else { "Five letters, please" }; + self.shake = Some(now); + self.toast = Some((text, now.wrapping_add(TOAST_MS))); + view::toast(&mut s, text, view::toast_y(self.g.n as usize)); + } + }, + } + self.api.show(); + } + + /// Animations; returns how long until the next frame is due. + fn animate(&mut self) -> u32 { + let now = self.api.now(); + let mut s = self.api; + let mut wait = u32::MAX; + if let Some((row, t0)) = self.reveal { + let k = (now.wrapping_sub(t0) / REVEAL_MS + 1) as usize; + if k > LEN { + self.reveal = None; + self.shown_tiles = LEN; + view::keyboard(&mut s, &self.g.hints(), false); + self.revealed(); + if self.mode == Mode::Shown { + self.end_toast(); + } + self.api.show(); + } else { + if k != self.shown_tiles { + self.shown_tiles = k; + view::board_row(&mut s, &self.g, row, k, 0); + self.api.show(); + } + wait = wait.min(left(now, t0.wrapping_add(k as u32 * REVEAL_MS))); + } + } + if let Some(t0) = self.shake { + let f = (now.wrapping_sub(t0) / SHAKE_MS) as usize; + let row = self.g.n as usize; + if f >= SHAKE.len() { + self.shake = None; + view::board_row(&mut s, &self.g, row, 0, 0); + } else { + view::board_row(&mut s, &self.g, row, 0, SHAKE[f]); + wait = wait.min(left(now, t0.wrapping_add((f as u32 + 1) * SHAKE_MS))); + } + self.api.show(); + } + if let Some((_, until)) = self.toast { + if due(now, until) { + self.toast = None; + view::board(&mut s, &self.g, None); + self.api.show(); + } else { + wait = wait.min(left(now, until)); + } + } + if self.mode == Mode::Shown { + if due(now, self.shown_until) { + self.mode = Mode::End; + self.draw(); + } else { + wait = wait.min(left(now, self.shown_until)); + } + } + if matches!(self.mode, Mode::Menu | Mode::End) { + wait = wait.min(CLOCK_MS); + } + wait + } + + fn tap(&mut self, x: i32, y: i32) { + match self.mode { + Mode::Menu => { + let Some(hit) = view::menu_hit(x, y) else { return }; + self.tick(); + match hit { + MenuHit::Daily => self.start_daily(), + MenuHit::Practice => self.start_practice(), + MenuHit::Stats => self.mode = Mode::Stats, + MenuHit::Help => self.mode = Mode::Help, + } + self.draw(); + } + Mode::Play => { + if self.reveal.is_none() { + if let Some(k) = view::key_at(x, y) { + if self.toast.is_some() && self.shake.is_none() { + // typing takes the message off + self.toast = None; + let mut s = self.api; + view::board(&mut s, &self.g, None); + } + self.key(k); + } + } + } + Mode::Shown => { + self.mode = Mode::End; + self.draw(); + } + Mode::End => match view::end_hit(x, y) { + Some(EndHit::Practice) => { + self.tick(); + self.sv.open = None; // a new word, also after a practice game + self.start_practice(); + self.draw(); + } + Some(EndHit::Menu) => { + self.mode = Mode::Menu; + self.draw(); + } + None => {} + }, + Mode::Stats => { + self.mode = Mode::Menu; + self.draw(); + } + Mode::Help => { + if view::help_hit_ticks(x, y) { + self.sv.ticks = !self.sv.ticks; + self.tick(); + self.save(); + } else { + self.mode = Mode::Menu; + } + self.draw(); + } + } + } + } + + // true on RESUME, false on BUTTON + fn paused(api: &Api) -> bool { + loop { + match api.event(u32::MAX).map(|e| e.kind) { + Some(RESUME) => return true, + Some(BUTTON) => return false, + _ => {} + } + } + } + + fn main(api: &'static Api) -> i32 { + let mut blob = [0u8; BLOB + 8]; + let n = api.load(&mut blob); + let sv = if n > 0 { Save::decode(&blob[..n as usize]).unwrap_or(Save::new()) } else { Save::new() }; + let mut app = App { + api, + motor: Motor::new(api), // dropped on return: the motor goes off + sv, + saved: sv, + g: Game::new(0), + daily: true, + mode: Mode::Menu, + reveal: None, + shown_tiles: LEN, + shake: None, + toast: None, + shown_until: 0, + clock: (0, 0), + }; + app.draw(); + let mut touch: Option<(i32, i32, u32)> = None; + loop { + app.motor.update(); + let wait = app.animate(); + let wait = app.motor.wait().map_or(wait, |m| m.min(wait)); + let Some(e) = api.event(wait) else { + // the clock moved: the countdown, or a new day on the start screen + if matches!(app.mode, Mode::Menu | Mode::End) && app.clock_key() != app.clock { + app.draw(); + } + continue; + }; + match e.kind { + BUTTON => { + app.settle(); + app.motor.off(); + app.keep(); + app.save(); + return 0; + } + PAUSE => { + touch = None; + app.settle(); + app.motor.off(); + app.keep(); + app.save(); // swiped away or a popup: the app may not come back + if !paused(api) { + return 0; + } + app.draw(); // the loader repainted the old frame + } + TOUCH_DOWN => touch = Some((e.x as i32, e.y as i32, api.now())), + TOUCH_UP => { + let Some((x, y, at)) = touch.take() else { continue }; + if api.now().wrapping_sub(at) <= TAP_MS { + app.tap(x, y); + } + } + CROWN if app.mode == Mode::Play && app.reveal.is_none() && e.delta < 0 => app.key(Key::Del), + _ => {} + } + } + } +} diff --git a/apps/word-guess/src/view.rs b/apps/word-guess/src/view.rs new file mode 100644 index 0000000..3b613c4 --- /dev/null +++ b/apps/word-guess/src/view.rs @@ -0,0 +1,732 @@ +//! The screens, drawn through `cmf_wp2_ui::Surface` so host tests see the watch's pixels. Black background, all text +//! in the system font's family (`cmf_wp2_ui::font`, Inter 20 px), the stock colours (`cmf_wp2_app::stock`). +//! +//! What a guess tells is shown by shape as well as colour, so it reads without telling colours apart: +//! +//! - right letter, right place: a solid accent square; +//! - in the word, elsewhere: an accent ring; +//! - not in the word: no tile at all, the letter dimmed. +//! +//! The keyboard keys wear the same marks. Game screen on the round 466×466 panel (`y` of text is the top of its +//! cell: caps start 2 px lower and are 14 px tall; the loader's status bar keeps the top 30 px): +//! +//! ```text +//! y 36..224 board: 6 rows × 5 tiles of 28 px, 32 px pitch +//! y 232..274 Q W E R T Y U I O P keys 40 × 42 on a 44 × 48 grid +//! y 280..322 A S D F G H J K L +//! y 328..370 Z X C V B N M +//! y 376..418 [ Del ] [ Enter ] +//! ``` +//! +//! A tap anywhere from y 229 down picks the nearest key of its row, so the keys' hit areas meet without gaps. + +use crate::game::{Game, Mark, ROWS, Stats, State}; +use crate::words::{LEN, capital}; +use cmf_wp2_ui::draw::{ring, rrect}; +use cmf_wp2_ui::font; +use cmf_wp2_ui::text::int; +use cmf_wp2_ui::{Rgb, Surface}; + +pub const BG: u16 = 0x0000; +pub const WHITE: u16 = 0xFFFF; +/// `stock::GREY`, `stock::ACCENT`, `stock::ROW_BG`, `stock::ROW_PRESSED`, `stock::LETTER_BG`. +pub const GREY: u16 = 0x8C92; +pub const ACCENT: u16 = 0xFA23; +pub const ROW_BG: u16 = 0x2966; +pub const PRESSED: u16 = 0x4229; +/// A letter known not to be in the word. +pub const DIM: u16 = 0x52AB; + +const fn rgb(c: u16) -> Rgb { + Rgb::from565(c) +} + +/// Caps of [`font`] text start this far below its `y` and are [`CAP`] tall. +const CAP_TOP: i32 = 2; +const CAP: i32 = 14; + +/// `y` for text whose caps are centred on `cy`. +const fn text_y(cy: i32) -> i32 { + cy - CAP / 2 - CAP_TOP +} + +// The board. +pub const TILE: i32 = 28; +const TILE_PITCH: i32 = 32; +pub const BOARD_X: i32 = 233 - (TILE_PITCH * (LEN as i32 - 1) + TILE) / 2; +pub const BOARD_Y: i32 = 36; +/// Corner radius of a square tile or key. +const TILE_R: i32 = 6; + +pub fn tile_x(col: usize) -> i32 { + BOARD_X + col as i32 * TILE_PITCH +} + +pub fn tile_y(row: usize) -> i32 { + BOARD_Y + row as i32 * TILE_PITCH +} + +// The keyboard. +const KEY_PITCH: i32 = 44; +const KEY_W: i32 = 40; +const KEY_H: i32 = 42; +pub const KB_TOP: i32 = 232; +const KB_PITCH: i32 = 48; +/// Taps from here down go to the keyboard. +pub const KB_HIT_TOP: i32 = KB_TOP - (KB_PITCH - KEY_H) / 2; +const KB_ROWS: [&[u8]; 3] = [b"qwertyuiop", b"asdfghjkl", b"zxcvbnm"]; +const WIDE_W: i32 = 128; +const WIDE_GAP: i32 = 8; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum Key { + /// A letter `1..=26`. + Letter(u8), + Enter, + Del, +} + +fn row_x(row: usize) -> i32 { + 233 - KB_ROWS[row].len() as i32 * KEY_PITCH / 2 +} + +/// Where a key is drawn: `(x, y, w, h)`. +pub fn key_box(k: Key) -> (i32, i32, i32, i32) { + let wide_y = KB_TOP + 3 * KB_PITCH; + match k { + Key::Letter(l) => { + for (r, keys) in KB_ROWS.iter().enumerate() { + if let Some(i) = keys.iter().position(|&c| c - b'a' + 1 == l) { + let x = row_x(r) + i as i32 * KEY_PITCH + (KEY_PITCH - KEY_W) / 2; + return (x, KB_TOP + r as i32 * KB_PITCH, KEY_W, KEY_H); + } + } + (0, 0, 0, 0) + } + Key::Del => (233 - WIDE_GAP / 2 - WIDE_W, wide_y, WIDE_W, KEY_H), + Key::Enter => (233 + WIDE_GAP / 2, wide_y, WIDE_W, KEY_H), + } +} + +#[cfg(test)] +pub fn key_centre(k: Key) -> (i32, i32) { + let (x, y, w, h) = key_box(k); + (x + w / 2, y + h / 2) +} + +/// The key a tap at (x, y) means: the nearest one in the row band it falls in. +pub fn key_at(x: i32, y: i32) -> Option { + if y < KB_HIT_TOP { + return None; + } + let row = ((y - KB_HIT_TOP) / KB_PITCH) as usize; + if row >= 3 { + return Some(if x < 233 { Key::Del } else { Key::Enter }); + } + let keys = KB_ROWS[row]; + let i = ((x - row_x(row)).div_euclid(KEY_PITCH)).clamp(0, keys.len() as i32 - 1) as usize; + Some(Key::Letter(keys[i] - b'a' + 1)) +} + +/// Every key, in drawing order. +fn all_keys() -> impl Iterator { + KB_ROWS.iter().flat_map(|r| r.iter().map(|&c| Key::Letter(c - b'a' + 1))).chain([Key::Del, Key::Enter]) +} + +fn clear(s: &mut impl Surface) { + s.rect(0, 0, 466, 466, BG); +} + +fn letter(s: &mut impl Surface, cx: i32, cy: i32, l: u8, c: u16) { + let mut b = [0u8; 4]; + let t = capital(l).encode_utf8(&mut b); + font::draw(s, cx - font::width(t) / 2, text_y(cy), t, c); +} + +/// A rounded box outline `t` px wide (inside is painted black). +fn outline(s: &mut impl Surface, x: i32, y: i32, w: i32, h: i32, r: i32, t: i32, c: u16) { + rrect(s, x, y, w, h, r, rgb(c), rgb(BG)); + rrect(s, x + t, y + t, w - 2 * t, h - 2 * t, r - t, rgb(BG), rgb(c)); +} + +/// One mark in a `w × h` box: the shared look of tiles and keys. `typed`: a letter of the row being typed. +fn marked(s: &mut impl Surface, x: i32, y: i32, w: i32, h: i32, l: u8, m: Mark, idle: u16) { + let (cx, cy) = (x + w / 2, y + h / 2); + s.rect(x, y, w, h, BG); + match m { + Mark::Correct => { + rrect(s, x, y, w, h, TILE_R, rgb(ACCENT), rgb(BG)); + letter(s, cx, cy, l, WHITE); + } + Mark::Present => { + let r = w.min(h) / 2; + ring(s, cx, cy, r - 3, r, rgb(ACCENT), rgb(BG)); + letter(s, cx, cy, l, WHITE); + } + Mark::Absent => letter(s, cx, cy, l, DIM), + Mark::Unknown if l == 0 => outline(s, x, y, w, h, TILE_R, 2, ROW_BG), + Mark::Unknown => { + rrect(s, x, y, w, h, TILE_R, rgb(idle), rgb(BG)); + letter(s, cx, cy, l, WHITE); + } + } +} + +/// A board tile: letter `l` (0 = empty) with mark `m`. +pub fn tile(s: &mut impl Surface, row: usize, col: usize, l: u8, m: Mark, dx: i32) { + marked(s, tile_x(col) + dx, tile_y(row), TILE, TILE, l, m, PRESSED); +} + +/// The letters and marks of board row `row`: guessed rows show `revealed` of their marks (the rest as typed), the +/// row being typed its letters, later rows nothing. +pub fn row_tiles(g: &Game, row: usize, revealed: usize) -> [(u8, Mark); LEN] { + let mut out = [(0, Mark::Unknown); LEN]; + if row < g.n as usize { + let m = g.marks(row); + for i in 0..LEN { + out[i] = (g.rows[row][i], if i < revealed { m[i] } else { Mark::Unknown }); + } + } else if row == g.n as usize && !g.over() { + for (i, o) in out.iter_mut().enumerate() { + o.0 = g.cur[i]; + } + } + out +} + +/// Repaints board row `row` shifted `dx` px (the shake of a refused guess). +pub fn board_row(s: &mut impl Surface, g: &Game, row: usize, revealed: usize, dx: i32) { + s.rect(BOARD_X - 16, tile_y(row), TILE_PITCH * LEN as i32 + 32, TILE, BG); + for (i, (l, m)) in row_tiles(g, row, revealed).into_iter().enumerate() { + tile(s, row, i, l, m, dx); + } +} + +/// The board, with row `reveal.0` showing only `reveal.1` of its marks. +pub fn board(s: &mut impl Surface, g: &Game, reveal: Option<(usize, usize)>) { + // wide enough for a toast's pill too + s.rect(233 - 140, BOARD_Y - 4, 280, TILE_PITCH * ROWS as i32 + 4, BG); + for row in 0..ROWS { + let k = match reveal { + Some((r, k)) if r == row => k, + _ => LEN, + }; + board_row(s, g, row, k, 0); + } +} + +pub fn key(s: &mut impl Surface, k: Key, hints: &[Mark; 27], ready: bool) { + let (x, y, w, h) = key_box(k); + match k { + Key::Letter(l) => marked(s, x, y, w, h, l, hints[l as usize], ROW_BG), + Key::Del | Key::Enter => { + let (label, bg) = if k == Key::Del { ("Del", ROW_BG) } else { ("Enter", if ready { ACCENT } else { ROW_BG }) }; + rrect(s, x, y, w, h, h / 2, rgb(bg), rgb(BG)); + font::centre(s, x + w / 2, text_y(y + h / 2), label, WHITE); + } + } +} + +/// The whole keyboard. `ready`: five letters typed, Enter lights up. +pub fn keyboard(s: &mut impl Surface, hints: &[Mark; 27], ready: bool) { + for k in all_keys() { + key(s, k, hints, ready); + } +} + +/// A message centred on `cy`: [`toast_y`] for one about a row, [`END_TOAST_Y`] at the end of a game. +pub fn toast(s: &mut impl Surface, text: &str, cy: i32) { + let w = font::width(text) + 40; + rrect(s, 233 - w / 2, cy - TOAST_H / 2, w, TOAST_H, TOAST_H / 2, rgb(WHITE), rgb(BG)); + font::centre(s, 233, text_y(cy), text, BG); +} + +/// Tall enough for a line, short enough to sit on the row below another without touching it. +const TOAST_H: i32 = 34; + +/// Where a message about board row `row` goes: over the next row, so the row itself stays in sight. +pub fn toast_y(row: usize) -> i32 { + let r = if row + 1 < ROWS { row + 1 } else { row.saturating_sub(1) }; + tile_y(r) + TILE / 2 +} + +/// The end of a game: over the keyboard's top row, the board stays in sight. +pub const END_TOAST_Y: i32 = KB_TOP + KEY_H / 2; + +/// The message at the end of a game, on a cleared band over the keyboard's top row (no longer needed). +pub fn end_toast(s: &mut impl Surface, text: &str) { + s.rect(0, KB_TOP - 2, 466, KEY_H + 4, BG); + toast(s, text, END_TOAST_Y); +} + +/// The game screen. +pub fn game(s: &mut impl Surface, g: &Game, reveal: Option<(usize, usize)>) { + clear(s); + board(s, g, reveal); + let hints = g.hints_rows(reveal.map_or(g.n as usize, |(r, _)| r)); + keyboard(s, &hints, g.len as usize == LEN); +} + +/// A small text buffer: no heap, no `core::fmt`. +pub struct Buf { + b: [u8; 40], + n: usize, +} + +impl Buf { + pub fn new() -> Buf { + Buf { b: [0; 40], n: 0 } + } + + pub fn s(&mut self, s: &str) -> &mut Buf { + let k = s.len().min(self.b.len() - self.n); + self.b[self.n..self.n + k].copy_from_slice(&s.as_bytes()[..k]); + self.n += k; + self + } + + pub fn n(&mut self, v: u32) -> &mut Buf { + let mut t = [0u8; 11]; + let s = int(v.min(i32::MAX as u32) as i32, &mut t); + self.s(s) + } + + /// Two digits, zero-padded. + pub fn n2(&mut self, v: u32) -> &mut Buf { + if v < 10 { + self.s("0"); + } + self.n(v) + } + + pub fn str(&self) -> &str { + core::str::from_utf8(&self.b[..self.n]).unwrap_or("?") + } +} + +impl Default for Buf { + fn default() -> Self { + Buf::new() + } +} + +fn pill(s: &mut impl Surface, x: i32, y: i32, w: i32, h: i32, label: &str, bg: u16) { + rrect(s, x, y, w, h, h / 2, rgb(bg), rgb(BG)); + font::centre(s, x + w / 2, text_y(y + h / 2), label, WHITE); +} + +// The start screen: title, four rows, the streak. + +pub const ROW_X: i32 = 63; +pub const ROW_W: i32 = 340; +pub const ROW_H: i32 = 56; +const MENU_TITLE_Y: i32 = 56; +pub const MENU_Y: [i32; 4] = [108, 172, 236, 300]; +const MENU_FOOT_Y: i32 = 378; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum MenuHit { + Daily, + Practice, + Stats, + Help, +} + +const MENU: [(MenuHit, &str); 4] = + [(MenuHit::Daily, "Daily"), (MenuHit::Practice, "Practice"), (MenuHit::Stats, "Statistics"), (MenuHit::Help, "How to play")]; + +pub fn menu_hit(x: i32, y: i32) -> Option { + if !(ROW_X - 30..ROW_X + ROW_W + 30).contains(&x) { + return None; + } + // each row's band reaches half the gap to the next + let gap = MENU_Y[1] - MENU_Y[0] - ROW_H; + MENU.iter().zip(MENU_Y).find(|&(_, top)| (top - gap / 2..top + ROW_H + gap / 2 + 1).contains(&y)).map(|(m, _)| m.0) +} + +/// The start screen. `daily`: what today's game is at ("Play", "2 of 6", "Solved 3/6", "Missed"); `practice`: +/// "Resume" for an unfinished one, else "". +pub fn menu(s: &mut impl Surface, daily: &str, practice: &str, streak: u16, best: u16) { + clear(s); + font::centre(s, 233, MENU_TITLE_Y, "Word Guess", WHITE); + for ((hit, label), y) in MENU.iter().zip(MENU_Y) { + rrect(s, ROW_X, y, ROW_W, ROW_H, ROW_H / 2, rgb(ROW_BG), rgb(BG)); + font::draw(s, ROW_X + 28, text_y(y + ROW_H / 2), label, WHITE); + let (value, c) = match hit { + MenuHit::Daily => (daily, if daily == "Play" { ACCENT } else { GREY }), + MenuHit::Practice => (practice, GREY), + _ => ("", GREY), + }; + font::draw(s, ROW_X + ROW_W - 28 - font::width(value), text_y(y + ROW_H / 2), value, c); + } + let mut b = Buf::new(); + b.s("Streak ").n(streak as u32).s(" Best ").n(best as u32); + font::centre(s, 233, MENU_FOOT_Y, b.str(), GREY); +} + +// Statistics: four numbers, then the guess distribution. + +const COL_PITCH: i32 = 92; +const BAR_MAX: i32 = 190; +/// Labels 26 px left of the bars; the whole block centred. +const BAR_X: i32 = 233 - (26 + BAR_MAX) / 2 + 26; +const BAR_H: i32 = 18; + +fn numbers(s: &mut impl Surface, y: i32, st: &Stats, today: Option) { + let vals = [st.played as u32, st.win_pct(), st.current(today) as u32, st.best as u32]; + for (i, (v, label)) in vals.into_iter().zip(["Played", "Win %", "Streak", "Best"]).enumerate() { + let cx = 233 + (2 * i as i32 - 3) * COL_PITCH / 2; + let mut b = Buf::new(); + b.n(v); + font::centre(s, cx, y, b.str(), WHITE); + font::centre(s, cx, y + 22, label, GREY); + } +} + +/// Wins by guesses: one bar per row count, `mark` (1-based) in the accent. +fn bars(s: &mut impl Surface, y: i32, pitch: i32, st: &Stats, mark: Option) { + let most = st.dist.iter().copied().max().unwrap_or(0).max(1) as i32; + for i in 0..ROWS { + let top = y + i as i32 * pitch; + let mut d = [0u8; 11]; + font::centre(s, BAR_X - 18, text_y(top + BAR_H / 2), int(i as i32 + 1, &mut d), GREY); + let n = st.dist[i]; + let mut b = [0u8; 11]; + let num = int(n as i32, &mut b); + let w = (n as i32 * BAR_MAX / most).max(font::width(num) + 14); + let c = if mark == Some(i + 1) { ACCENT } else { ROW_BG }; + rrect(s, BAR_X, top, w, BAR_H, 4, rgb(c), rgb(BG)); + font::draw(s, BAR_X + w - 7 - font::width(num), text_y(top + BAR_H / 2), num, WHITE); + } +} + +pub const BACK_Y: i32 = 336; +pub const BACK_W: i32 = 160; + +pub fn stats(s: &mut impl Surface, daily: &Stats, practice: &Stats, today: Option) { + clear(s); + font::centre(s, 233, 52, "Statistics", WHITE); + numbers(s, 88, daily, today); + bars(s, 144, 22, daily, None); + let mut b = Buf::new(); + b.s("Practice ").n(practice.played as u32).s(" played, ").n(practice.win_pct()).s("% won"); + font::centre(s, 233, 286, b.str(), GREY); + pill(s, 233 - BACK_W / 2, BACK_Y, BACK_W, 52, "Back", ROW_BG); +} + +// The end of a game. + +pub const END_BTN_Y: i32 = 340; +pub const END_BTN_H: i32 = 52; +const END_BTN_W: i32 = 146; +const END_BTN_GAP: i32 = 12; + +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +pub enum EndHit { + /// Practice after the daily game, another practice word after a practice one. + Practice, + Menu, +} + +pub fn end_hit(x: i32, y: i32) -> Option { + if !(END_BTN_Y - 14..END_BTN_Y + END_BTN_H + 30).contains(&y) || !(40..426).contains(&x) { + return None; + } + Some(if x < 233 { EndHit::Practice } else { EndHit::Menu }) +} + +/// After a game: how it went, the word, a line (`Next word in 05:12`, or the practice tally), the statistics of +/// its kind and the buttons. +pub fn end(s: &mut impl Surface, g: &Game, st: &Stats, today: Option, line: &str, daily: bool) { + clear(s); + let won = g.state() == State::Won; + let mut b = Buf::new(); + if won { + b.s("Solved in ").n(g.n as u32); + } else { + b.s("The word was"); + } + font::centre(s, 233, 46, b.str(), if won { WHITE } else { GREY }); + let w = g.word(); + for (i, &l) in w.iter().enumerate() { + marked(s, 233 - 102 + i as i32 * 42, 72, 36, 36, l, Mark::Correct, ROW_BG); + } + font::centre(s, 233, 118, line, GREY); + numbers(s, 148, st, today); + bars(s, 200, 21, st, if won { Some(g.n as usize) } else { None }); + let x0 = 233 - END_BTN_GAP / 2 - END_BTN_W; + pill(s, x0, END_BTN_Y, END_BTN_W, END_BTN_H, if daily { "Practice" } else { "Again" }, ACCENT); + pill(s, 233 + END_BTN_GAP / 2, END_BTN_Y, END_BTN_W, END_BTN_H, "Menu", ROW_BG); +} + +/// The text line of [`end`] for a daily game: the time to the next word. +pub fn countdown(b: &mut Buf, until: Option<(u32, u32)>) { + match until { + Some((h, m)) => { + b.s("Next word in ").n2(h).s(":").n2(m); + } + None => { + b.s("Next word at midnight"); + } + } +} + +// How to play. + +pub const TICKS_Y: i32 = 318; +const TICKS_W: i32 = 300; + +pub fn help_hit_ticks(x: i32, y: i32) -> bool { + (TICKS_Y - 6..TICKS_Y + ROW_H + 6).contains(&y) && (233 - TICKS_W / 2 - 20..233 + TICKS_W / 2 + 20).contains(&x) +} + +pub fn help(s: &mut impl Surface, ticks: bool) { + clear(s); + font::centre(s, 233, 44, "How to play", WHITE); + font::centre(s, 233, 76, "Find the word in six tries.", GREY); + font::centre(s, 233, 100, "Each guess marks its letters:", GREY); + let legend = [(23u8, Mark::Correct, "Right place"), (15, Mark::Present, "In the word, elsewhere"), (18, Mark::Absent, "Not in the word")]; + for (i, (l, m, text)) in legend.into_iter().enumerate() { + let y = 136 + i as i32 * 42; + marked(s, 76, y, 32, 32, l, m, ROW_BG); + font::draw(s, 124, text_y(y + 16), text, WHITE); + } + font::centre(s, 233, 270, "A new daily word at midnight", GREY); + rrect(s, 233 - TICKS_W / 2, TICKS_Y, TICKS_W, ROW_H, ROW_H / 2, rgb(ROW_BG), rgb(BG)); + font::draw(s, 233 - TICKS_W / 2 + 28, text_y(TICKS_Y + ROW_H / 2), "Key ticks", WHITE); + let v = if ticks { "On" } else { "Off" }; + font::draw(s, 233 + TICKS_W / 2 - 28 - font::width(v), text_y(TICKS_Y + ROW_H / 2), v, if ticks { ACCENT } else { GREY }); + font::centre(s, 233, 392, "Tap to go back", GREY); +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::game::{Save, Submit}; + use crate::words::{self, word}; + use cmf_wp2_ui::{Fb, SIZE}; + + fn screen() -> Vec { + vec![0u16; (SIZE * SIZE) as usize] + } + + /// Nothing lit within `margin` px of the round edge or outside it, nor in the status bar's band. + fn fits(px: &[u16], margin: i32) -> Result<(), (i32, i32)> { + let r = 233 - margin; + for y in 0..SIZE { + for x in 0..SIZE { + let (dx, dy) = (2 * x + 1 - SIZE, 2 * y + 1 - SIZE); + let lit = px[(y * SIZE + x) as usize] != 0; + if lit && (dx * dx + dy * dy > 4 * r * r || y < 30) { + return Err((x, y)); + } + } + } + Ok(()) + } + + fn game_for(answer: &str) -> Game { + let w = word(answer); + let i = (0..words::ANSWER_COUNT).find(|&i| words::answer(i) == w).unwrap(); + Game::new(i as u16) + } + + fn play(g: &mut Game, s: &str) -> Submit { + for c in s.bytes() { + g.letter(c - b'a' + 1); + } + g.submit() + } + + fn big_stats() -> Stats { + Stats { played: 9999, wins: 9998, streak: 999, best: 9999, last_win: 0, dist: [9999, 5000, 1, 0, 70, 9999] } + } + + #[test] + fn every_screen_fits_the_circle() { + let mut mid = game_for("crane"); + play(&mut mid, "trace"); + play(&mut mid, "nacre"); + play(&mut mid, "cr"); + let mut full = game_for("crane"); + for w in ["ghost", "plumb", "dizzy", "fjord", "whisk", "vouch"] { + play(&mut full, w); + } + let st = big_stats(); + let mut b = Buf::new(); + countdown(&mut b, Some((23, 59))); + let line = b.str().to_string(); + let cases: Vec<(&str, Box)> = vec![ + ("menu", Box::new(|s| menu(s, "Solved 6/6", "Resume", 9999, 9999))), + ("game", Box::new(|s| game(s, &mid, None))), + ("game revealing", Box::new(|s| game(s, &mid, Some((1, 2))))), + ("game lost", Box::new(|s| game(s, &full, None))), + ("shake", Box::new(|s| { + game(s, &mid, None); + board_row(s, &mid, 2, 0, -8); + board_row(s, &mid, 2, 0, 8); + })), + ("toast", Box::new(|s| { + game(s, &mid, None); + toast(s, "Not in word list", toast_y(2)); + toast(s, "Five letters, please", toast_y(5)); + end_toast(s, "First try!"); + })), + ("end won", Box::new(|s| end(s, &mid, &st, Some(1), &line, true))), + ("end lost", Box::new(|s| end(s, &full, &st, Some(1), "Practice 9999 of 9999", false))), + ("stats", Box::new(|s| stats(s, &st, &st, Some(0)))), + ("help on", Box::new(|s| help(s, true))), + ("help off", Box::new(|s| help(s, false))), + ]; + for (name, draw) in cases { + let mut px = screen(); + draw(&mut Fb::new(&mut px)); + assert_eq!(fits(&px, 6), Ok(()), "{name}"); + } + } + + #[test] + fn every_key_centre_hits_its_key() { + for k in all_keys() { + let (x, y) = key_centre(k); + assert_eq!(key_at(x, y), Some(k), "{k:?}"); + let (bx, by, w, h) = key_box(k); + // the drawn box's corners too + for (px, py) in [(bx, by), (bx + w - 1, by), (bx, by + h - 1), (bx + w - 1, by + h - 1)] { + assert_eq!(key_at(px, py), Some(k), "{k:?} at {px},{py}"); + } + } + assert_eq!(all_keys().count(), 28); + for l in 1..=26u8 { + assert_ne!(key_box(Key::Letter(l)).2, 0, "letter {l} has a key"); + } + } + + #[test] + fn hit_areas_are_generous_and_stop_at_the_board() { + // between keys and past the row ends: still the nearest key + let (qx, qy) = key_centre(Key::Letter(17)); // q + assert_eq!(key_at(qx - 30, qy), Some(Key::Letter(17))); + let (px, py) = key_centre(Key::Letter(16)); // p + assert_eq!(key_at(px + 30, py), Some(Key::Letter(16))); + let (_, ay) = key_centre(Key::Letter(1)); + assert_eq!(key_at(5, ay), Some(Key::Letter(1))); + assert_eq!(key_at(233, 460), Some(Key::Enter)); + assert_eq!(key_at(10, 440), Some(Key::Del)); + // the rows' bands meet: every y from the top of the keyboard down lands on some key + for y in KB_HIT_TOP..466 { + assert!(key_at(233, y).is_some(), "{y}"); + } + assert_eq!(key_at(233, KB_HIT_TOP - 1), None); + assert_eq!(key_at(233, tile_y(5) + TILE / 2), None); + // keys are big enough to hit + let (_, _, w, h) = key_box(Key::Letter(1)); + assert!(w >= 40 && h >= 42); + assert!(KB_HIT_TOP > tile_y(ROWS - 1) + TILE); + } + + #[test] + fn tiles_show_their_marks_by_shape() { + let mut g = game_for("crane"); + play(&mut g, "nacre"); // P P P P C + play(&mut g, "ghost"); // all absent + play(&mut g, "cr"); + let mut px = screen(); + let mut fb = Fb::new(&mut px); + game(&mut fb, &g, None); + let corner = |fb: &Fb, r: usize, c: usize| fb.at(tile_x(c) + 2, tile_y(r) + 2); + // correct: a filled square, so its corner is lit + assert_eq!(corner(&fb, 0, 4), ACCENT); + // present: a ring, the corner stays dark and the ring's top is lit + assert_eq!(corner(&fb, 0, 0), BG); + assert_eq!(fb.at(tile_x(0) + TILE / 2, tile_y(0) + 2), ACCENT); + // absent: no tile + assert_eq!(corner(&fb, 1, 0), BG); + assert_eq!(fb.at(tile_x(0) + TILE / 2, tile_y(1) + 1), BG); + // typed: a filled grey tile; empty: an outline + assert_eq!(corner(&fb, 2, 0), PRESSED); + assert_eq!(fb.at(tile_x(3) + TILE / 2, tile_y(2) + TILE / 2), BG); + assert_eq!(fb.at(tile_x(3), tile_y(2) + TILE / 2), ROW_BG); + // keys follow the hints + let at = |fb: &Fb, l: u8| { + let (x, y, _, _) = key_box(Key::Letter(l)); + fb.at(x + 4, y + 4) + }; + assert_eq!(at(&fb, 5), ACCENT); // e: right place + assert_eq!(at(&fb, 14), BG); // n: ring + assert_eq!(at(&fb, 7), BG); // g: absent + assert_eq!(at(&fb, 26), ROW_BG); // z: unknown + } + + #[test] + fn row_repaints_match_a_full_repaint() { + let mut g = game_for("crane"); + play(&mut g, "trace"); + let mut px = screen(); + let mut fb = Fb::new(&mut px); + game(&mut fb, &g, Some((0, 0))); + for k in 1..=LEN { + board_row(&mut fb, &g, 0, k, 0); + } + keyboard(&mut fb, &g.hints(), false); + g.letter(3); + tile(&mut fb, 1, 0, 3, Mark::Unknown, 0); + let mut want = screen(); + game(&mut Fb::new(&mut want), &g, None); + assert!(px == want, "partial repaints left something behind"); + } + + #[test] + fn a_toast_goes_without_a_trace_and_spares_its_row() { + let mut g = game_for("crane"); + play(&mut g, "trace"); + play(&mut g, "nacre"); + let mut want = screen(); + game(&mut Fb::new(&mut want), &g, None); + for row in 0..ROWS { + let mut px = screen(); + let mut fb = Fb::new(&mut px); + game(&mut fb, &g, None); + toast(&mut fb, "Five letters, please", toast_y(row)); + // the row it is about is untouched + for y in tile_y(row)..tile_y(row) + TILE { + for x in 0..SIZE { + assert_eq!(px[(y * SIZE + x) as usize], want[(y * SIZE + x) as usize], "row {row} at {x},{y}"); + } + } + let mut fb = Fb::new(&mut px); + board(&mut fb, &g, None); + assert!(px == want, "row {row}: the toast left something behind"); + } + } + + #[test] + fn menu_end_and_help_taps() { + for (i, m) in [MenuHit::Daily, MenuHit::Practice, MenuHit::Stats, MenuHit::Help].into_iter().enumerate() { + assert_eq!(menu_hit(233, MENU_Y[i] + ROW_H / 2), Some(m)); + assert_eq!(menu_hit(ROW_X + 4, MENU_Y[i] + 2), Some(m)); + } + assert_eq!(menu_hit(233, MENU_TITLE_Y), None); + assert_eq!(end_hit(150, END_BTN_Y + 20), Some(EndHit::Practice)); + assert_eq!(end_hit(320, END_BTN_Y + 20), Some(EndHit::Menu)); + assert_eq!(end_hit(233, 200), None); + assert!(help_hit_ticks(233, TICKS_Y + 20)); + assert!(!help_hit_ticks(233, 150)); + } + + #[test] + fn countdown_and_buffer() { + let mut b = Buf::new(); + countdown(&mut b, Some((5, 7))); + assert_eq!(b.str(), "Next word in 05:07"); + let mut b = Buf::new(); + countdown(&mut b, None); + assert_eq!(b.str(), "Next word at midnight"); + let mut b = Buf::new(); + for _ in 0..20 { + b.s("abc"); + } + assert_eq!(b.str().len(), 40); + let _ = Save::new(); + } +} diff --git a/apps/word-guess/src/words.rs b/apps/word-guess/src/words.rs new file mode 100644 index 0000000..62f0500 --- /dev/null +++ b/apps/word-guess/src/words.rs @@ -0,0 +1,215 @@ +//! The word lists, `data/guesses.txt` and `data/answers.txt` (made by `tools/gen_words.py`; sources and licences +//! in `WORDS.md`), packed into the image at build time by the `const fn`s below: no text of them is linked in. +//! +//! A word is five letters `1..=26` (a = 1), packed five bits each into a `u32`, first letter highest, so numeric +//! order is alphabetical order and a typed word is found by binary search in [`GUESSES`] (8 636 × 4 B). The answers +//! are `u16` indices into [`GUESSES`], in the fixed shuffled order the daily word walks through; an answer that is +//! not a valid guess stops the build. + +pub const LEN: usize = 5; + +/// A word as letters `1..=26`. +pub type Word = [u8; LEN]; + +const GUESS_TXT: &[u8] = include_bytes!("../data/guesses.txt"); +const ANSWER_TXT: &[u8] = include_bytes!("../data/answers.txt"); + +/// Words in a list: its letters over five (line ends, `\r` included, are skipped). +const fn count(t: &[u8]) -> usize { + let (mut i, mut n) = (0, 0); + while i < t.len() { + if t[i].is_ascii_lowercase() { + n += 1; + } + i += 1; + } + assert!(n % LEN == 0, "a word list has a word that is not five letters"); + n / LEN +} + +pub const GUESS_COUNT: usize = count(GUESS_TXT); +pub const ANSWER_COUNT: usize = count(ANSWER_TXT); + +const fn pack_list(t: &[u8]) -> [u32; N] { + let mut out = [0u32; N]; + let (mut i, mut k, mut w, mut letters) = (0, 0, 0u32, 0); + while i < t.len() { + let c = t[i]; + if c.is_ascii_lowercase() { + w = w << 5 | (c - b'a' + 1) as u32; + letters += 1; + if letters == LEN { + out[k] = w; + k += 1; + w = 0; + letters = 0; + } + } else { + assert!(letters == 0, "a word list line is not five letters"); + } + i += 1; + } + out +} + +const fn find(list: &[u32], w: u32) -> Option { + let (mut lo, mut hi) = (0, list.len()); + while lo < hi { + let mid = (lo + hi) / 2; + if list[mid] == w { + return Some(mid); + } else if list[mid] < w { + lo = mid + 1; + } else { + hi = mid; + } + } + None +} + +const fn index_list(answers: &[u32; N], guesses: &[u32]) -> [u16; N] { + let mut out = [0u16; N]; + let mut i = 0; + while i < N { + match find(guesses, answers[i]) { + Some(k) => out[i] = k as u16, + None => panic!("an answer is not in the guess list"), + } + i += 1; + } + out +} + +const GUESS_WORDS: [u32; GUESS_COUNT] = pack_list(GUESS_TXT); +/// Every word that may be typed, sorted. +pub static GUESSES: [u32; GUESS_COUNT] = GUESS_WORDS; +/// The hidden words as indices into [`GUESSES`], in daily order. +pub static ANSWERS: [u16; ANSWER_COUNT] = index_list(&pack_list::(ANSWER_TXT), &GUESS_WORDS); + +pub fn pack(w: &Word) -> u32 { + w.iter().fold(0u32, |acc, &l| acc << 5 | (l & 31) as u32) +} + +pub fn unpack(v: u32) -> Word { + let mut w = [0u8; LEN]; + for (i, l) in w.iter_mut().enumerate() { + *l = (v >> (5 * (LEN - 1 - i)) & 31) as u8; + } + w +} + +/// Is `w` a word you may guess? +pub fn is_word(w: &Word) -> bool { + w.iter().all(|&l| (1..=26).contains(&l)) && GUESSES.binary_search(&pack(w)).is_ok() +} + +/// Hidden word number `i` (taken modulo the list). +pub fn answer(i: usize) -> Word { + unpack(GUESSES[ANSWERS[i % ANSWER_COUNT] as usize]) +} + +/// The answer index for day `day` (days since 2026-12-01, local date): the same for everyone on that date. +pub fn daily(day: i32) -> usize { + day.rem_euclid(ANSWER_COUNT as i32) as usize +} + +/// A letter `1..=26` as its capital. +pub fn capital(l: u8) -> char { + if (1..=26).contains(&l) { (b'A' + l - 1) as char } else { ' ' } +} + +#[cfg(test)] +pub fn word(s: &str) -> Word { + let b = s.as_bytes(); + let mut w = [0u8; LEN]; + for i in 0..LEN { + w[i] = b[i].to_ascii_lowercase() - b'a' + 1; + } + w +} + +#[cfg(test)] +mod tests { + use super::*; + + fn text(w: &Word) -> String { + w.iter().map(|&l| capital(l)).collect() + } + + #[test] + fn lists_have_their_sizes() { + assert!((8000..=13000).contains(&GUESS_COUNT), "{GUESS_COUNT}"); + assert!((1800..=2500).contains(&ANSWER_COUNT), "{ANSWER_COUNT}"); + assert_eq!(GUESS_COUNT, std::str::from_utf8(GUESS_TXT).unwrap().lines().count()); + assert_eq!(ANSWER_COUNT, std::str::from_utf8(ANSWER_TXT).unwrap().lines().count()); + } + + #[test] + fn guesses_are_sorted_and_unique() { + assert!(GUESSES.windows(2).all(|p| p[0] < p[1])); + } + + #[test] + fn every_answer_is_a_valid_guess_once() { + let mut seen = std::collections::HashSet::new(); + for i in 0..ANSWER_COUNT { + let w = answer(i); + assert!(is_word(&w), "{}", text(&w)); + assert!(seen.insert(w), "{} twice", text(&w)); + } + } + + #[test] + fn packing_round_trips_and_keeps_order() { + for s in ["aaaaa", "zzzzz", "crane", "abbey", "fuzzy"] { + assert_eq!(text(&unpack(pack(&word(s)))), s.to_uppercase()); + } + assert!(pack(&word("abbey")) < pack(&word("abide"))); + assert!(pack(&word("azzzz")) < pack(&word("baaaa"))); + assert_eq!(pack(&word("aaaaa")), 0b00001_00001_00001_00001_00001); + for (i, line) in std::str::from_utf8(GUESS_TXT).unwrap().lines().enumerate().step_by(97) { + assert_eq!(GUESSES[i], pack(&word(line.trim())), "{line}"); + } + } + + #[test] + fn the_answers_keep_the_file_order() { + let lines: Vec<&str> = std::str::from_utf8(ANSWER_TXT).unwrap().lines().map(str::trim).collect(); + for (i, l) in lines.iter().enumerate() { + assert_eq!(text(&answer(i)), l.to_uppercase()); + } + } + + #[test] + fn binary_search_finds_words_and_only_words() { + for s in ["about", "crane", "zesty", "aahed", "zymes", "fjord"] { + assert!(is_word(&word(s)), "{s}"); + } + for s in ["aaaaa", "xqzvb", "abcde", "zzzzz", "crans"] { + assert!(!is_word(&word(s)), "{s}"); + } + // first and last of the list and their neighbours + assert!(is_word(&unpack(GUESSES[0]))); + assert!(is_word(&unpack(GUESSES[GUESS_COUNT - 1]))); + assert!(!is_word(&unpack(GUESSES[0] - 1))); + assert!(!is_word(&unpack(GUESSES[GUESS_COUNT - 1] + 1))); + assert!(!is_word(&[0, 1, 2, 3, 4])); + } + + #[test] + fn days_map_to_words() { + assert_eq!(daily(0), 0); + assert_eq!(daily(1), 1); + assert_eq!(daily(-1), ANSWER_COUNT - 1); + assert_eq!(daily(ANSWER_COUNT as i32), 0); + for d in -400..4000 { + assert_ne!(answer(daily(d)), answer(daily(d + 1)), "day {d}"); + } + // a whole cycle shows every answer once + let mut seen = vec![false; ANSWER_COUNT]; + for d in 0..ANSWER_COUNT as i32 { + seen[daily(d)] = true; + } + assert!(seen.iter().all(|&s| s)); + } +} diff --git a/apps/word-guess/store.md b/apps/word-guess/store.md new file mode 100644 index 0000000..024fec7 --- /dev/null +++ b/apps/word-guess/store.md @@ -0,0 +1,31 @@ +Find the hidden five-letter word in six tries. Type a guess on the keyboard and tap **Enter**: every letter of it is +marked. + +- A **solid square**: the letter is in the word, in this place. +- A **ring**: the letter is in the word, somewhere else. +- **No tile**, the letter dimmed: it is not in the word (or not as many times as you typed it). + +The keys of the keyboard wear the same marks, so you can see at a glance which letters are left. The marks differ in +shape as well as colour, so they read without telling colours apart. A guess has to be a real word: anything else is +turned away with "Not in word list" and a short buzz, and costs you nothing. **Del** (or a turn of the crown) takes the +last letter back. + +**Daily**: one word per day, the same for everyone on that date, a new one at midnight. You get one game a day; leave +in the middle and it picks up where you were. When it is done, you see how long until the next word. + +**Practice**: as many random words as you like. They are counted on their own and never touch your daily streak. + +**Statistics**: games played, the share you solved, your current and best daily streaks, and how many guesses your +wins took. Everything, the game in progress included, is kept on the watch. A key tick can be turned off under +**How to play**. Press the crown or swipe right to leave. + +## Requirements + +The [patched firmware](/firmware) and the [App Loader](/firmware). Open it from the **Apps** row at the end of the +watch's app list (list style, not the waterfall). + +## Word lists + +1,890 hidden words, the common five-letter head words of Alan Beale's 12dicts (public domain), and 8,636 words you may +guess, from the ENABLE word list (public domain). Details in +[WORDS.md](https://github.com/fmctools/apps/blob/main/apps/word-guess/WORDS.md). diff --git a/apps/word-guess/store.toml b/apps/word-guess/store.toml new file mode 100644 index 0000000..b646fc8 --- /dev/null +++ b/apps/word-guess/store.toml @@ -0,0 +1,6 @@ +# The app's listing in the FMC store (README.md, "store.toml"). The page's body is store.md. +name = "Word Guess" +summary = "Guess the hidden five-letter word in six tries. A new word every day, and practice" +version = "0.1.0" +author = "Ziyad Eslam" +screenshots = ["shots/menu.png", "shots/playing.png", "shots/end.png"] diff --git a/apps/word-guess/tools/gen_words.py b/apps/word-guess/tools/gen_words.py new file mode 100644 index 0000000..2d8561f --- /dev/null +++ b/apps/word-guess/tools/gen_words.py @@ -0,0 +1,129 @@ +#!/usr/bin/env python3 +"""Builds Word Guess's word lists: data/guesses.txt (every word you may type) and data/answers.txt (the hidden +words, in the fixed order the daily word walks through). + +Inputs (download them yourself; nothing is fetched here): + + ENABLE enable1.txt, the Enhanced North American Benchmark LExicon, public domain. + https://raw.githubusercontent.com/dolph/dictionary/master/enable1.txt + (the script prints its sha256; WORDS.md records the one used) + 12dicts 12dicts 6.0.2 by Alan Beale, public domain ("acknowledgment requested"), file Lemmatized/2+2+3frq.txt. + http://downloads.sourceforge.net/wordlist/12dicts-6.0.2.zip, see http://wordlist.aspell.net/12dicts/ + +Run from anywhere: + + python apps/word-guess/tools/gen_words.py --enable enable1.txt --frq 12dicts/Lemmatized/2+2+3frq.txt + +Filters: + + guesses every five-letter ENABLE word (lowercase a-z only), sorted. The app packs each into 25 bits at build time + (`src/words.rs`) and finds a typed word by binary search. + answers five-letter head words (lemmas: no plural or past forms) of 2+2+3frq in frequency classes 1..MAX_CLASS + (the most common English words), lowercase a-z only (no proper nouns), that ENABLE has too, minus + - words ending in "s" whose first four letters are a word (plural-looking: "jeans", "blues"), + - BLOCK: offensive, crude or upsetting words. + Shuffled with a fixed seed by a self-contained PRNG (splitmix64 + Fisher-Yates), so the order is the same + on every machine and Python version. The daily word for local date D is + answers[(days from 2026-12-01 to D) mod len(answers)]. + +Changing either list changes every future daily word: raise the app's version and say so in the changelog. +""" + +import argparse +import hashlib +import pathlib +import re + +MAX_CLASS = 16 +SEED = 0x57_47_2026_1201 # "WG", 2026-12-01 + +# Words that may be valid but are no fun to be handed as the word of the day. +BLOCK = set( + """ + bitch whore pussy penis dildo semen sperm horny boobs booby busty butch enema feces urine pubic + negro gypsy gipsy honky kraut spick dykes homos queer skank bimbo pimps porno sexed + lynch slave rapes raped nazis idiot moron fatso fatty hussy prick cunts dicks titty turds + bigot booty chink jihad kinky mammy pygmy welsh dutch roman mecca wacko loony leper fecal sissy lusty + nappy grope vomit obese + """.split() +) +assert all(len(w) == 5 for w in BLOCK) +KEEP_S = {"chaos", "ethos", "bonus", "focus", "virus"} # end in s, not plurals + + +def enable_words(path): + words = set() + for line in pathlib.Path(path).read_text(encoding="ascii").splitlines(): + w = line.strip() + if re.fullmatch(r"[a-z]+", w): + words.add(w) + return words + + +def frequency_lemmas(path): + """(class, head word) in file order; inflected forms (indented lines) are skipped.""" + cls = 0 + out = [] + for line in pathlib.Path(path).read_text(encoding="latin-1").splitlines(): + m = re.match(r"^-+ (\d+) -+", line) + if m: + cls = int(m.group(1)) + elif line and not line[0].isspace(): + out.append((cls, line.strip())) + return out + + +def splitmix64(state): + while True: + state = (state + 0x9E3779B97F4A7C15) & 0xFFFFFFFFFFFFFFFF + z = state + z = ((z ^ (z >> 30)) * 0xBF58476D1CE4E5B9) & 0xFFFFFFFFFFFFFFFF + z = ((z ^ (z >> 27)) * 0x94D049BB133111EB) & 0xFFFFFFFFFFFFFFFF + yield z ^ (z >> 31) + + +def shuffle(items, seed): + rng = splitmix64(seed) + items = list(items) + for i in range(len(items) - 1, 0, -1): + j = next(rng) % (i + 1) + items[i], items[j] = items[j], items[i] + return items + + +def main(): + ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + ap.add_argument("--enable", required=True, help="enable1.txt") + ap.add_argument("--frq", required=True, help="12dicts Lemmatized/2+2+3frq.txt") + ap.add_argument("--out", default=str(pathlib.Path(__file__).resolve().parent.parent / "data")) + args = ap.parse_args() + + enable = enable_words(args.enable) + guesses = sorted(w for w in enable if len(w) == 5) + + answers = [] + seen = set() + for cls, w in frequency_lemmas(args.frq): + if cls > MAX_CLASS or w in seen or not re.fullmatch(r"[a-z]{5}", w) or w not in enable: + continue + if w in BLOCK: + continue + if w.endswith("s") and w not in KEEP_S and not w.endswith(("ss", "us", "is")) and w[:4] in enable: + continue + seen.add(w) + answers.append(w) + answers = shuffle(sorted(answers), SEED) + + assert set(answers) <= set(guesses) + assert len(guesses) < 1 << 16, "answers are stored as u16 indices into the guesses" + + out = pathlib.Path(args.out) + out.mkdir(parents=True, exist_ok=True) + (out / "guesses.txt").write_bytes("".join(w + "\n" for w in guesses).encode("ascii")) + (out / "answers.txt").write_bytes("".join(w + "\n" for w in answers).encode("ascii")) + sha = hashlib.sha256(pathlib.Path(args.enable).read_bytes()).hexdigest() + print(f"guesses {len(guesses)}, answers {len(answers)}, enable1.txt sha256 {sha}") + + +if __name__ == "__main__": + main()