Skip to content

feat: add Word Chain AI word association game - #76

Open
nicks-agent wants to merge 8 commits into
mainfrom
feat/word-chain
Open

feat: add Word Chain AI word association game#76
nicks-agent wants to merge 8 commits into
mainfrom
feat/word-chain

Conversation

@nicks-agent

Copy link
Copy Markdown
Collaborator

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 words
  • WordChainApi.ts — Client-side API helper
  • index.mdx — Lab experiment page entry
  • components.ts — Lab component registry update

How it works

  1. Player gets a starting word
  2. Type a word that's associated with the previous one
  3. AI validates the association and scores it
  4. Keep the chain going as long as you can

Built by Ren 🤖

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]>
@vercel

vercel Bot commented Mar 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nicknish-web Ready Ready Preview, Comment Mar 5, 2026 8:21am

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants