I asked GPT to make a simple zombie game — and it actually ran on my phone.
Exploring AI-Generated Code: A Simple Zombie Dodging Game Runs Seamlessly on a Phone
In recent experiments with AI-driven code generation, I tasked GPT with creating a straightforward “zombie dodging” game, with the crucial requirement that it be functional on a mobile device. The outcome was surprisingly effective—immediately playable on my phone despite its simplicity and rough edges.
The Challenge and the Process
My goal was to see whether GPT could produce a complete, minimalistic game that adhered to practical usability constraints for mobile platforms. I emphasized portability, which meant the game needed to run smoothly in a mobile browser without extensive adjustments.
The core gameplay involved controlling a player character using keyboard arrows to avoid oncoming zombies. Here’s an outline of the mechanics I asked GPT to implement:
- Lateral movement via arrow keys
- Collision detection to determine when a zombie hits the player
- Game over notification upon collision
While the code was not polished and the difficulty balancing was inconsistent, the fact that it was playable right out of the box was impressive. Here’s a snippet of the implementation:
“`javascript
// Player movement logic (left/right arrow keys)
document.addEventListener(“keydown”, (e) => {
if (e.key === “ArrowLeft”) player.x -= 10; // Move left
if (e.key === “ArrowRight”) player.x += 10; // Move right
});
// Collision detection (game ends when zombie hits player)
function checkCollision(zombie, player) {
if (
player.x < zombie.x + zombie.size &&
player.x + player.size > zombie.x &&
player.y < zombie.y + zombie.size &&
player.y + player.size > zombie.y
) {
alert(“💀 Game Over!”);
}
}
“`
(Note: The original code was generated with the aid of a translation app, so some phrasing may seem unusual.)
Reflections and Questions
This experiment raises a broader question about the capabilities of AI in software development. Have you had similar experiences where GPT or other language models provided code that was not only syntactically correct but also immediately usable? Or do you typically find that AI-generated snippets require extensive debugging and rework?
The potential for AI to assist in creating simple, functional projects is promising, especially for rapid prototyping or learning purposes. As AI tools improve, the boundary between generated and deployable code continues to blur.
Conclusion
While there is
Post Comment