Back to Projects

Genius or Idiot

A PHP-based quiz game determining if you are a genius or an idiot based on your knowledge of creature anatomy.

About this Project

'Genius or Idiot' is a backend-focused web game built to demonstrate Object-Oriented Programming (OOP) principles in pure PHP. Players are challenged to correctly identify specific attributes of various creatures (like the number of legs on a spider or eyes on a human). The application serves as a practical example of concepts like inheritance, polymorphism, and encapsulation, moving beyond simple procedural PHP scripts.

Features

  • Strict OOP architecture with abstract base classes and inheritance
  • Polymorphic game logic handling various creature types uniformly
  • Persistent score tracking using a PostgreSQL database
  • Dynamic question generation based on creature classes
  • MVC-inspired structure (Model, View, Controller)

Challenges & Solutions

The Challenge

The main challenge was moving away from the typical procedural PHP style often found in simple tutorials and enforcing a strict Object-Oriented architecture. Implementing a game loop and state management in a stateless HTTP environment without relying on a heavy framework required careful design of the Kernel and Game classes.

The Solution

I implemented an abstract `Creature` class to define the contract for all game entities, allowing the `Game` class to interact with any new creature type via polymorphism without code changes. A `ScoreManager` handles database interactions for persistence, while a custom `Kernel` manages the request/response lifecycle, ensuring a clean separation of concerns.