DEV Community

Sakthivadivel Easwaramoorthy
Sakthivadivel Easwaramoorthy

Posted on

Article by Sakthivadivel - Full Stack Developer

From Minecraft to Multiplication: Building an AI-Powered "Math Gatekeeper" for Windows 11

Weโ€™ve all been there. You sit down to do some work, but your child has already hijacked your Windows 11 machine. The sounds of explosions and blocky characters fill the room. You try the classic "just five more minutes," but you know it's a lie. The loop continues. ๐ŸŽฎ

But what if instead of a frustrating power-off, we implemented an intelligent intervention? What if the game didn't just stop, but transformed into a high-stakes, adaptive learning session?

In this article, we are going to architect a theoretical (but entirely buildable!) AI Math Gatekeeper. We arenโ€™t just talking about a simple pop-up; we are talking about an Agentic AI system that monitors processes, generates dynamic curriculum via LLMs, and uses a Vector Store to track learning progress.


๐Ÿ—๏ธ The Architecture of the "Gatekeeper" Agent

To build this, we need more than just a Python script. We need a multi-layered AI agent architecture.

1. The Sentinel (Process Monitoring)

The first layer is a lightweight monitor that tracks active Windows processes. Using libraries like psutil, the system watches for specific high-intensity gaming processes (like Minecraft.exe or RobloxPlayerBeta.exe). Once a time threshold (e.g., 60 minutes) is breached, the "Intervention Protocol" is triggered.

2. The Oracle (Generative AI)

Static math questions are boring and easy to memorize. Instead, we use an LLM (like GPT-4o or Llama 3). When the pop-up triggers, the Agent calls the LLM to generate five unique, age-appropriate math problems. Because it's generative, no two "lockouts" are ever the same.

3. The Tutor (Agentic Feedback Loop)

This is where it gets Agentic. If the child answers a question incorrectly, the Agent doesn't just move to the next one. It analyzes the error. Did they struggle with carrying numbers in addition? The Agent dynamically adjusts the difficulty of the remaining questions to provide remedial support.

4. The Memory (Vector Store)

By using a Vector Database (like ChromaDB or Pinecone), we store the results of every session. We convert the "session logs" into embeddings. Over time, the system can identify patterns: "User struggles with multiplication by 7 on Friday afternoons."


'## ๐Ÿ’ป Implementation Blueprint

Let's look at how you might implement the core "Brain" of this gatekeeper using Python and an LLM integration.

The Generative Brain

This snippet demonstrates how we use an LLM to generate a randomized, non-repetitive math challenge.

import openai

def generate_math_challenge(age, difficulty_level="easy"):
    """
    Uses GenAI to create 5 randomized math questions 
    based on the child's age and current performance.
    """
    prompt = f"""
    You are a friendly math tutor for a {age}-year-old.
    Generate 5 math questions that are {difficulty_level}.
    Format: Return only a JSON list of strings.
    Example: ["5 + 3 = ?", "10 - 4 = ?"]
    """

    response = openai.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": prompt}],
        response_format={ "type": "json_object" }
    )

    return response.choices[0].message.content

# Example usage
questions = generate_math_challenge(age=7)
print(f"New Challenge Generated: {questions}")
Enter fullscreen mode Exit fullscreen mode

The Monitoring Sentinel

A simplified version of the background process monitor.

import psutil
import time

def monitor_gaming_time(process_name, threshold_seconds):
    start_time = None

    print(f"๐Ÿ›ก๏ธ Sentinel Active: Monitoring {process_name}...")

    while True:
        # Check if the game process is running
        is_running = any(proc.name() == process_name for proc in psutil.process_iter())

        if is_running:
            if start_time is None:
                start_time = time.time()
                print("๐ŸŽฎ Game detected! Timer started.")

            elapsed_time = time.time() - start_time

            if elapsed_time > threshold_seconds:
                print("๐Ÿšจ THRESHOLD REACHED! Triggering AI Gatekeeper...")
                trigger_math_interruption()
                break # Stop monitoring once the gate is triggered
        else:
            start_time = None # Reset if game is closed

        time.sleep(5) # Check every 5 seconds

def trigger_math_interruption():
    # In a real app, this would launch a Windows GUI overlay
    print("โš ๏ธ POP-UP ACTIVE: Solve the math problems to continue playing!")

# Start monitoring Minecraft for 1 hour (3600 seconds)
# monitor_gaming_time("Minecraft.exe", 3600)
Enter fullscreen mode Exit fullscreen mode

๐Ÿš€ Key Takeaways for Developers

If you are looking to implement or experiment with this pattern, keep these key points in mind:

  • Dynamic Difficulty Scaling: Use the LLM's reasoning capabilities to evaluate the correctness of the answer and adjust the next prompt's complexity.
  • Contextual Awareness: A true Agentic system doesn't just look at the current question; it looks at the Vector Store (history) to see if the child is improving or regressing.
  • Non-Intrusive Monitoring: For production-grade tools, use low-overhead monitoring to ensure the "Sentinel" doesn't impact gaming performance (FPS).
  • The "Gamification" Opportunity: You can extend this by adding rewards (e.g., "Correct answers earn 5 extra minutes of playtime").

๐Ÿ Final Thoughts

We are entering an era where software is no longer static. We are moving from Deterministic Software (if X, then Y) to Agentic Software (if X, observe, learn, and adapt). Transforming a simple parental restriction into an intelligent, personalized tutoring session is a perfect microcosm of what Gen AI can do for the world.

The "Math Gatekeeper" isn't just about stopping a game; it's about using the tools of the future to turn every digital distraction into a moment of growth.

What do you think? Would you use an AI Agent to manage your household tasks or even your professional workflow? Let's discuss in the comments! ๐Ÿ‘‡

ai #python #genai #agenticai #machinelearning #coding

Top comments (1)

Collapse
 
topstar_ai profile image
Luis Cruz

I'm intrigued by the concept of the "Agentic AI system" and how it leverages LLMs to generate dynamic curriculum for the Math Gatekeeper. The use of a Vector Store to track learning progress is particularly interesting, as it allows for the identification of patterns in the child's performance over time. The example code snippet for the generate_math_challenge function demonstrates how the LLM can be used to create randomized math questions based on the child's age and difficulty level. Have you considered implementing any additional features, such as providing feedback to parents or educators on the child's progress, or integrating with existing learning management systems?