About Me
I am Mohd Ibrahim, a Bootcamp Student and AI Explorer. As I head into 2026, I am focusing on bridging the gap between traditional software development and generative AI. With this portfolio project, I wanted to express that AI isn't just a "chatbot" interface—it can be a core engine for creativity, world-building, and dynamic systems in gaming.
Portfolio
🎮 Play SENTINEL.EXE Live Here
Note: For the best experience, please use a Desktop browser.
How I Built It
SENTINEL.EXE is a cyber-noir Tower Defense game where the player defends a "Human History Core" from sentient logic bombs.
Players take on the role of the last active security protocol in a dying supercomputer. Your mission is to deploy experimental subroutines (towers) to prevent sentient logic bombs (viruses) from reaching the "Human History Core."
"In a world of collapsing data, you are the last line of defense."
The Tech Stack
- Engine: Python 3.12 (Pygame-ce)
- AI: Google Gemini 2.0 Flash (via google-genai SDK)
- Web Tech: WebAssembly (WASM), Pygbag, Flask
- Cloud: Google Cloud Run, Docker, Google Artifact Registry
Google AI Integration
I treated Gemini 2.0 Flash as a critical system component rather than a gimmick:
Procedural Lore: Gemini handles the world-building, generating unique backstories for the supercomputer environment.
Event-Driven Architecture: To keep the game at a smooth 60 FPS, I implemented an asynchronous pattern where AI calls are offloaded to background threads during "Pre-Wave" states.
Responsible AI & Robustness: I built a Fail-Safe Architecture. If the API hits a rate limit or a network error occurs, the system gracefully falls back to a "Local Lore" subroutine, ensuring the game remains fully functional and immersive even offline.
What I'm Most Proud Of
I am most proud of the Robustness Logic and the Thread-Safe AI Integration. Offloading Gemini API calls to a background thread allowed me to keep the gameplay smooth while generating dynamic content in real-time.
Integrating a cloud-based LLM into a real-time game loop presents significant latency challenges. Successfully implementing a background thread system that allows the game to render while waiting for Gemini's response—combined with a "Tactical Cooldown" to respect Free Tier rate limits—felt like a major engineering win. It demonstrates that AI-powered games can be both high-concept and technically stable.
I'm particularly proud of the Environment-Aware Logic. The game automatically detects if it's running in a browser or on a PC. It switches from a full AI-powered tactical advisor on desktop to a high-performance, local-fallback mode on the web, providing a seamless experience regardless of the platform.
Technical Hurdles
1. The Async Transition (Desktop vs. WebAssembly)
The Problem: Pygame is traditionally a synchronous, blocking library designed for desktop CPUs. When I first tried to port the game to the web using Pygbag, the browser tab would completely freeze. The Solution: I had to refactor the entire core engine to use asyncio. By implementing await asyncio.sleep(0) inside the main loop, I allowed the browser’s JavaScript engine to "breathe," handling events and rendering frames without locking up the user's interface.
2. Managing the AI Bottleneck
The Problem: Calling the Gemini API is a "heavy" I/O operation. If I called the AI directly inside the game loop, the game would "hitch" or pause for 1–2 seconds while waiting for the network response, killing the "real-time" feel of a tower defense game. The Solution: I implemented a multi-threaded/asynchronous approach. I moved the API calls to background threads and used asyncio.to_thread for the lore generation. This ensured that while Gemini was "thinking" of a gritty virus taunt, the towers were still firing and the viruses were still moving at a smooth 60 FPS.
3. Containerizing a Hybrid App
The Problem: Running a Pygbag-built static site inside a Python Flask server on Google Cloud Run required a specific folder architecture that differed from my local development environment. I initially ran into ModuleNotFoundError because of how Python handles sub-directory imports. The Solution: I reorganized the project into a strict game/ and app/ structure. I used a custom Dockerfile to serve the Wasm-compiled assets via Flask, ensuring that Google Cloud Run could scale the game infinitely while maintaining the correct MIME types for the .wasm and .js files.
4. The 'Ghost Layer' Architecture: Bypassing Static Analysis
The Problem: The biggest hurdle was deploying a Python game with AI dependencies (Google GenAI) to the web. The Pygbag compiler normally crashes when it sees desktop-only libraries. I solved this by building a 'Ghost Layer' using importlib. This allowed me to dynamically load AI modules only on Desktop, effectively 'hiding' them from the web compiler and ensuring a stable WebAssembly build.
How to Play: Operation SENTINEL.EXE
Objective: Protect the Human History Core (the cyan square at the center) from incoming virus packets. If your system integrity hits 0%, the firewall is breached and the data is lost.
-
Deploying Defenses: Click anywhere on the grid to deploy a Firewall Node (Tower).
- Cost: 50 Ghz (CPU Cycles) per node.
CPU Cycles (Ghz): This is your primary resource. You gain 10 Ghz for every virus packet purged. Use them wisely—don't run out of "clock speed" when a big wave hits!
AI Tactical Advisor: Press [H] during gameplay to request a Tactical Sync. Gemini will analyze your current integrity and cycles to provide a one-sentence defense tip. (Note: Has a 15-second cooldown to prevent CPU throttling).
** Lore Initialization** : Press [SPACE] at the start menu to have Gemini generate the current wave's sector lore.
** System Reboot** : If the core is breached, press [R] to re-initialize the firewall and try a new strategy.
💡 Pro-Tips
Focus Fire: Place nodes near the center to maximize their coverage of the core.
Manage Latency: If playing on the web, look for the Local Fallback messages—they demonstrate the game's ability to remain playable even if the AI API is under heavy load.
Top comments (0)