About This Log
This document chronicles the collaborative development of the Wordiverse word search game using GitHub Copilot in Visual Studio Code. Each entry captures the conversation, code, and reasoning behind our design decisions, serving as a learning resource for students and educators.
User Play Logic:
The Wordiverse game now supports interactive, user-friendly play through a series of clear, staged steps:
- Click/toggle letters in the grid: Users select or deselect grid letters by clicking. Each selected cell is visually highlighted.
- View their values: The app collects the values (letters) of the selected cells for further processing.
- Alphabetize their values: The selected letters are alphabetized to allow for flexible word matching, regardless of selection order.
- Scan for a match with placed words: The app compares the alphabetized selection to the
lettersattribute of eachPlacedWordobject. - If a match is found: The selected cells are colorized using the word’s assigned color, the word is crossed out in the placed words list, and the words found counter is updated.
- Clear Selection: Users can clear their current selection at any time using the "Clear Selection" button, which is conveniently placed next to the "Check Word" button.
Key JavaScript:
- PlacedWord.js class:
ThePlacedWordclass now includes alettersattribute, which stores an alphabetized string of the word’s letters. This enables flexible matching regardless of the order in which the user selects the letters.class PlacedWord { constructor(word, color, locnVector) { this.word = word; this.color = color; this.locnVector = locnVector; this.letters = word.split('').sort().join(''); } // ... } - checkForMatch function:
This function (user-inspired!) is central to gameplay. It alphabetizes the selected letters and checks for a match with any placed word. If a match is found, it colorizes the selection, crosses out the word in the list, and updates the counter.function checkForMatch() { const checkedLetters = selection.map(cell => cell.textContent).join(''); const alphabetizedCheckedLetters = checkedLetters.split('').sort().join(''); let foundWord = null; for (let pw of placedWordInfo) { if (pw.letters === alphabetizedCheckedLetters) { foundWord = pw; break; } } if (foundWord) { // Colorize, cross out, update counter, etc. } // Selection is only cleared on success }
Important CSS:
The following CSS classes provide clear visual feedback for user actions:
.selected: Highlights currently selected grid cells..selected { outline: 2px dashed #007bff; background-color: #e6f2ff; }.found-cell: Styles cells that are part of a found word, using the word’s color..found-cell { border: 1px solid #ccc !important; background-color: var(--found-color, #ffe066) !important; color: #222; /* ... */ }.found-word: Applies a line-through and color to found words in the list..found-word { font-weight: bold; font-style: italic; background-color: var(--found-color, #ffe066); transition: background 0.3s; }
This staged, user-driven approach has made the game more intuitive and visually engaging, while the modular code and CSS ensure maintainability and clarity for classroom use.
Teacher's note: While trying to implement Copilots suggestions in Collaboration#2, we hit many problems. Eventually, I had to start over and break things down step by step. Here's the prompt I gave Copilot for this Collaboration, #3:
Sometimes we can get greedy and ask Copilot to do too much!?
Problem: The Wordiverse app is not currently designed for mobile or small-screen environments. The grid and input areas require a minimum width for usability and proper display.
Solution: We added a warning message that appears when the browser window is less than 1000px wide. The main input and grid areas are hidden in this case, and users are prompted to use a desktop or resize their browser. This is achieved with a #mobileWarning div and a CSS media query:
@media (max-width: 999px) {
#primaryContent, #jumbotron {
display: none !important;
}
#mobileWarning {
display: block !important;
}
}
#mobileWarning {
display: none;
background: #ffdddd;
color: #a94442;
border: 2px solid #a94442;
border-radius: 8px;
margin: 2em auto;
padding: 2em;
max-width: 600px;
text-align: center;
font-size: 1.3em;
font-weight: bold;
}
This ensures users are clearly informed and prevents layout issues on unsupported devices.
This log will grow as we continue to develop and improve the Wordiverse app. Each entry will provide insight into the coding process, problem-solving strategies, and the power of collaborative tools like GitHub Copilot in the classroom.