v3: added MistakeIdentification_v3-1 GameContentDatabase_v8-2_no-macro.xlsx
v2: added the selection mechanism required that the number of ions selected correspond to the ratio of ions in the chemical formula as a way of nudging students to consider the balance of charges which is reflected in the chemical formula.
2 cations; 2 anions is marked as ok, it is reduce to 1 : 1
Require that the number of ions selected correspond to what’s needed for the charges to be balanced in an ionic compound
- wRiteFormulaPDF_SLS_20250424_210409.zip
- wRiteFormulaPDF_SLS_20250427_154935.zip added level 20 end game added level + - to allow user to test different levels.
wRiteFormulaPDF/
wRiteFormulaPDF_SLS_20250424_210409.zip
Key Requirements:
-
Curriculum-aligned ionic bonding logic
-
Intuitive tile-based gameplay with responsive feedback
-
Gamified elements like scoring and streaks
-
MCQs based on student misconceptions
Laying the Groundwork: From Idea to Codebase
We began by breaking down the PDF into actionable tasks and setting up the foundational code using the write_to_file
tool in Cline:
<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
<title>wRiteFormula v2</title>
<link rel="stylesheet" href="/ospsg/style.css">
</head>
<body>
<h1>wRiteFormula v2 Challenge</h1>
<!-- Interactive Elements -->
<script src="/ospsg/script.js"></script>
</body>
</html>
From there, script.js
and style.css
served as the main engines of game logic and design.
Core Gameplay Implementation
Development centered around the script.js
file. Major milestones included:
-
Ion Database (
allIons
): Each ion was defined with its name, charge, type, and oxidation state. -
Level Logic (
levelDefinitions
): Difficulty progressed over 20 levels, with each level offering specific cation/anion combinations. -
Tile Grid Generation (
populateIonGrid
): Dynamically populated based on level, with responsive layouts. -
User Interaction (
handleTileClick
): Enabled users to select one cation and one anion, activating a “Form Compound” button. -
Chemical Formula Calculation (
calculateFormula
): Used charge balancing via LCM and included special formatting for polyatomic ions. -
Compound Naming (
generateCompoundName
): Respected IUPAC naming conventions, including Roman numerals. -
Quiz Mechanism (MCQs):
-
Randomized question type (name or formula)
-
Plausible distractors based on real student errors
-
Instant feedback and scoring logic
-
Iterative Improvements and Bug Fixes
New Levels
wRiteFormulaPDF/ wRiteFormulaPDF_SLS_20250424_210409.zip |
Initial deployment covered levels 1–15.
wRiteFormulaPDF/ wRiteFormulaPDF_SLS_20250424_210409.zip |
Based on user feedback, levels 16–20 were added with rare ions like CrO₄²⁻
, CN⁻
, and Pt²⁺
.
Debugging Highlights
-
ReferenceError: charge2
: Scope error resolved by elevatinggcd
and replacing local variables. -
SyntaxError: Unexpected token '<'
: Caused by HTML tags in feedback strings—resolved by safely extracting text from elements before injection.
Enhanced Engagement
-
Sound Effects: Triggered on tile selection and quiz results using
.play()
onAudio
objects. -
Responsive Design:
-
Reduced tile count on mobile
-
Used CSS Grid with
auto-fit
and media queries
-
-
Scoring Adjustment: Simplified scoring logic to match student feedback.
Final Touches: Packaging and Publishing
-
Analytics: Added Google Analytics tracking for usage insights.
-
Attribution: Credit line included at the bottom of
index.html
for Trae.ai, Cline, Gemini 2.5 Pro, and iwant2study.org. -
SLS Zip Package: A ZIP archive containing only the runtime essentials (
index.html
,style.css
,script.js
,sounds/
) was created via:
tar -a -c -f wRiteFormula_SLS_20250424_210409.zip index.html script.js style.css sounds
AI as a Development Partner
This project illustrates the power of embedding AI into the development pipeline:
Task | AI Contribution |
---|---|
Requirement Parsing | Extracted structured logic from PDFs and images |
Code Generation | Built and edited HTML, CSS, and complex JavaScript |
File Operations | Read, wrote, replaced content in real-time |
Debugging | Diagnosed errors and proposed multiple fixes |
Packaging | Created distributable files for SLS |
The collaborative interplay between AI and human insight enabled rapid prototyping, iterative enhancement, and classroom-ready deployment—all within days, not weeks.
Conclusion
wRiteFormula v2 stands as a testament to the potential of AI-augmented development in education. By blending clear educational goals with powerful AI tooling, what began as a static PDF became a dynamic, gamified learning experience—scalable, interactive, and aligned with modern pedagogy.
Whether you're an educator, developer, or edtech enthusiast, this project demonstrates how AI can help build the future of learning—one compound at a time.
[text]
For Teachers
[SIMU_TEACHER]
Software Requirements
[SIMU_SWREQ]
Translation
[text]
Research
[text]
Video
[text]
Credits
[SIMU_CREDITS]
Version:
https://weelookang.blogspot.com/2025/04/building-writeformula-ai-powered.html
Other Resources
[text]