feat: add Word Chain AI word association game - #76
Open
nicks-agent wants to merge 8 commits into
Open
Conversation
Adds a new interactive experiment at /lab/word-chain — a word association game where players build the longest possible chain of related words, with each guess validated in real time by an LLM via OpenRouter. - content/experiments/word-chain/wordList.ts: 50 diverse seed words - content/experiments/word-chain/WordChainApi.ts: typed fetch helper - content/experiments/word-chain/WordChain.tsx: full game component with Cloudflare Turnstile bot protection, dark gradient UI, CSS keyframe animations (slide-in pills, input shake, pulse glow, chain replay), localStorage high score, and duplicate-word detection - content/experiments/word-chain/index.mdx: experiment page with frontmatter - src/app/api/lab/word-chain/route.ts: POST route with Turnstile verification and OpenRouter (z-ai/glm-4.5-air:free) for word association judgement - src/app/lab/components.ts: register WordChain component in experiment registry pnpm build passes. Biome lint clean. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…padding - Stop requiring Turnstile verification on every word submission (tokens are single-use; the initial gate is sufficient bot protection) - Don't end the game when LLM validation fails — show error and let player retry - Add more padding to Play Again button
The z-ai/glm-4.5-air:free model is a reasoning model that spends tokens on chain-of-thought before producing content. With max_tokens: 100, it burned all tokens on reasoning and returned content: null, causing every word validation to fail with 'Couldn't validate'. - Increase max_tokens from 100 to 300 - Increase timeout from 10s to 15s - Fall back to reasoning field if content is null
Free-tier OpenRouter models are predominantly reasoning models that spend tokens on chain-of-thought and often return content: null. - Bump max_tokens from 300 to 1000 so reasoning models can finish - Try multiple models in sequence (glm-4.5-air → mistral → arcee) - Extract JSON from reasoning field as fallback when content is null - Add 'Do NOT think step-by-step' to system prompt to discourage excessive reasoning - Clean up debug logging
- Log each model attempt, HTTP status, and response details - Log when API key is missing - Log when all models fail (with the word pair) - Return 502 (not 200) when AI validation can't be completed - Client handles 502 as retryable error
- Move arcee-ai/trinity-mini:free to first in model fallback chain (faster latency than glm-4.5-air) - Move score bar from absolute positioning into normal flow to prevent overlap with chain pills - Chain pills now scroll horizontally (nowrap) instead of wrapping over the input field - Add padding to Start Game button (px-10 py-4) - Add padding to Play Again button
- Start Game button: larger padding (16px 48px), bigger font - Content aligned to top of game container with 48px top padding instead of vertically centered - Increased gap between title/description, turnstile, and button (gap-6 → gap-8) - More breathing room in container padding (28px → 40px sides)
… spacing - Re-center game container vertically (was top-aligned, looked unbalanced) - Move chain pills below the input/submit area so they don't overlap - Chain pills are smaller (0.75rem) and centered with wrap + maxHeight - Score bar uses explicit 24px gap to prevent 'Chain:0Best:0' merging - Increased gap between playing-phase sections (gap-5 → gap-6) Verified locally with browser screenshots.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a Word Chain game to the lab — an AI-powered word association game where you guess related words in a chain (e.g. Knight → Castle → Queen).
Changes
WordChain.tsx— Main game component with animated UI, scoring, hints, and chain visualization (654 lines)route.ts— API route that uses AI to validate word associations and generate chains (182 lines)wordList.ts— Curated word list for starting wordsWordChainApi.ts— Client-side API helperindex.mdx— Lab experiment page entrycomponents.ts— Lab component registry updateHow it works
Built by Ren 🤖