Asif Iqbal_
← Projects

Rock Paper Scissors Spock Lizard

A command-line implementation of the strategy game from 'The Big Bang Theory' with player name customization, score tracking, and balanced gameplay.

Stack
Python 3Standard Library
Topics
PythonCLIGamesGame Logic

The problem

Creating a game requires careful rule implementation, input validation, and state management. The classic Rock Paper Scissors is trivial, but Rock Paper Scissors Spock Lizard adds complexity—each move must beat exactly two others and lose to exactly two others. Getting the rules right and making them maintainable is non-obvious.

Approach

The game uses a modular architecture with clear separation of concerns:

  • Entity module defines Player and Computer entities with consistent interfaces
  • Rules module encapsulates all game logic and win condition checks
  • Game module handles the main game loop and user interaction
  • Scoreboard module tracks scores persistently across sessions

Each component is isolated, making the rules easy to verify and test.

Key features

Balanced Gameplay — Each of the five moves beats exactly 2 out of 5 opponent moves, creating a perfectly fair 40% win rate with zero dominant strategy.

Player Tracking — Enter your name once and track wins/losses across multiple games with a persistent scoreboard.

Clear Game Rules — Based on the canonical rules from "The Big Bang Theory," with Sheldon Cooper's memorable explanation built into the game.

No External Dependencies — Uses only Python's standard library, making it trivial to run on any machine with Python 3.6+.

Interactive CLI — Simple, responsive command-line interface with immediate feedback on moves and outcomes.

What was interesting

Balanced game design. The rules must form a perfect cycle where no move dominates. Each move (Rock, Paper, Scissors, Spock, Lizard) beats exactly two others and loses to two others, creating a perfectly fair game where each move has a 40% win rate against random play. Representing this relationship clearly in code makes the win condition checks elegant rather than brittle.

Modular entity design. Both the player and computer are represented by the same entity interface, making the game flow logic symmetric and easier to reason about.

Persistent state. Score tracking that survives across sessions requires thoughtful file handling without external dependencies—pure Python I/O done carefully.

Architecture

├── main.py        # Entry point and CLI setup
├── game.py        # Main game loop and orchestration
├── rules.py       # All game logic and win condition checks
├── entity.py      # Player and Computer data structures
└── scoreboard.py  # Score tracking and persistence

The modular design means adding new features (like multiplayer, difficulty levels, or statistics) would slot in cleanly without refactoring core logic.

Result

A complete, playable game that demonstrates clean Python architecture. The code is readable enough for someone learning game logic, yet organized well enough to extend with new features. No external dependencies means it runs anywhere Python runs.