Files
homework5/PROPOSAL_20220899.md
2026-04-22 08:58:01 +09:00

3.7 KiB

My proposal

Basic Information

Video Game: nag a ram

nag a ram is an anagram game that helps English speakers improve problem-solving skills and build vocabulary.

An anagram is a word or phrase made by using the letters of another word or phrase in a different order. For example, silent and listen are anagrams. triangle, alerting, integral, and relating are all anagrams of one another.

*nag a ram is an anagram of anagram.

Game Mechanics

How to Play

  1. A base word appears on screen. The player can choose the number of letters beforehand or leave it random.
  2. Drag the letter tiles to rearrange them into a valid anagram before time runs out. The time limit scales with word length — longer words get more time.
  3. Press Complete to submit the answer.
  4. If correct, the player earns points and can save the word to a personal vocabulary list for later review.
  5. If incorrect or time runs out, one life is lost. The player has 5 lives per session. Once all lives are spent, there is a 5-minute cooldown before the game can be restarted.

Constraints

  • Word: Single word only
  • Time: Scales with word length
  • Lives: 5 per session

Scoring

  • Base points: Awarded per correct answer, scaled by word length
  • Streak bonus: Multiplied by consecutive correct answers
  • Easter egg: Double points for palindrome answers

Interface

The letter tiles are designed to resemble wooden blocks, giving the game a tactile, physical feel reminiscent of classic word games like Scrabble.

pic

Technical Implementation

Random Word API

The base word is randomly generated using the Random Word API with a length parameter.

For example, https://random-word-api.herokuapp.com/word?length=9 returns:

["triangle"]

Anagramica API

Once base word fetched from the Random Word API, the Anagramica API is used to verify at least one valid anagram (excluding the base word itself) exists. If the player's submission matches any word in the array, the answer is validated.

For example, http://www.anagramica.com/best/:triangle returns:

{
  "best": ["alerting", "altering", "integral", "relating", "triangle"]
}

Word module

  • fetchRandomWord(length): Fetches a random word from the Random Word API with the specified or random length
  • fetchAnagrams(word): Fetches valid anagrams from the Anagramica API
    • Uses .filter() to exclude the base word and ensure at least one valid anagram exists
  • validateAnswer(answer, anagrams): Checks if the player's input matches a valid anagram
    • Uses .includes() to search the anagram array
  • isPalindrome(answer): Checks if the given word is a palindrome
    • Uses recursion to compare letters inward from both ends

Game class

Manages state: score, timer, lives, streak

  • addScore(wordLength): Calculates and adds points based on word length, applies the streak multiplier, and doubles points if the palindrome check passes
  • startTimer(wordLength, onTick, onTimeUp): Starts a countdown scaled to word length
  • stopTimer(): Stops the timer, either when the player submits an answer or when time runs out
  • deductLife(): Removes a life and resets the streak
  • isGameOver(): Checks if all lives have been used

Vocabulary class

Use of AI

AI was used to paraphrase and refine the written content of this proposal.