Inspiration
Science is often taught as a collection of formulas and predetermined answers. Students may learn how to calculate an outcome without developing the intuition to predict why it happens. We built CounterFactual Lab around a different learning loop: commit to a prediction, observe the experiment, explain the evidence, and then test how changing one variable changes the result. Our goal was to make scientific thinking feel active, visual, and personal—not like memorizing another worksheet.
What it does
CounterFactual Lab uses AI to turn a student’s science question or diagram into an interactive 3D experiment. Before the simulation begins, the learner must predict the outcome and record their confidence. The app deliberately hides the trajectory and answer-revealing measurements until that prediction is locked in. After running the experiment, the learner can: Inspect the motion and measured evidence Compare the result with their prediction Explain the scientific mechanism in their own words Receive AI-guided feedback based on a learning rubric Change one variable and make a new counterfactual prediction Complete a transfer challenge that tests whether the concept was actually understood Instead of simply showing an animation, CounterFactual Lab turns that animation into a complete learning experience.
How we built it
We built the application with Next.js, TypeScript, React, and Three.js. Our AI pipeline analyzes the learner’s question, identifies the learning objective and likely misconception, and generates a structured experiment specification. That specification is schema-validated and checked for consistency before it can reach the renderer. The AI does not decide the correct physics result. Deterministic simulation code calculates outcomes such as trajectory, range, collisions, and measurements. This keeps the experiment scientifically consistent while allowing AI to personalize its subject and teaching strategy. After the experiment, a second AI workflow evaluates the learner’s explanation against a concept-specific rubric. Scores are calculated by the application rather than blindly accepted from the model. We also built responsive 3D controls, prediction-state safeguards, confidence tracking, counterfactual comparisons, accessibility features, provenance labels, graceful fallbacks, and automated unit and browser tests.
Challenges we ran into
The hardest challenge was combining generative AI with deterministic science. Language models can produce incomplete or inconsistent structures, so we created strict schemas, server-side validation, automatic repair, and physics-derived correct answers. We also had to prevent the simulation from accidentally revealing the answer. Early trajectory guides made the prediction meaningless, so we changed the experience to hide trajectories and telemetry until the learner commits. Making an information-dense 3D laboratory work on both large displays and phones was another challenge. We added responsive layouts, touch-friendly controls, focused zooming, recentering, keyboard support, and shortcuts that move mobile learners directly between the simulation and prediction notebook. Finally, AI services can be slow or unavailable. We designed transparent error and fallback states so the application never pretends that a prebuilt demonstration was generated for the learner’s question.
Accomplishments that we're proud of
We are proud that CounterFactual Lab is more than an AI wrapper or a visually impressive simulation. AI personalization, deterministic physics, evidence-based reasoning, and learning assessment all work together as one experience. We are especially proud of: Requiring learners to commit before seeing the answer Keeping correct outcomes controlled by physics rather than the language model Giving feedback on reasoning, not just right-or-wrong answers Teaching counterfactual thinking by changing one variable at a time Comparing first and second runs through visible evidence Building a polished, responsive 3D experience with honest AI provenance
What we learned
We learned that educational AI is most useful when it creates opportunities for thinking instead of immediately providing answers. We also learned that generative and deterministic systems are strongest when they have clearly separated responsibilities. AI can interpret a question, personalize an experiment, identify misconceptions, and evaluate an explanation. A validated physics engine should remain responsible for what actually happens. Most importantly, we learned that a simulation becomes a learning tool only when the learner is asked to predict, explain, revise, and transfer their understanding.
What's next for CounterFactual Lab
Next, we want to expand the library of validated experiment types, improve generation speed, and support more topics such as springs, collisions, energy, waves, and orbital motion. We also want to add saved experiment reports, teacher dashboards, classroom sharing, accessibility testing with real learners, and longitudinal mastery tracking. Our larger vision is a personal scientific laboratory where every student can turn curiosity into an experiment—and every experiment into deeper understanding.
Log in or sign up for Devpost to join the conversation.