Skip to content
Low Level Design Mastery Logo
LowLevelDesign Mastery

Design Snake and Ladder Game

Design a multi-player board game with randomized movement and state management.

Design a Snake and Ladder game that allows multiple players to play on a standard 10×10 board (100 squares) with configurable snakes and ladders. Players take turns in round-robin order, rolling a simulated die (1-6) and moving their pieces. Rolling a 6 grants an extra turn. The game should handle snake bites (moving down) and ladder climbs (moving up), detect when a player wins (lands exactly on square 100), and allow multiple players to occupy the same square.

In this problem, you’ll design a system that supports multiple players, configurable board entities, and a robust game loop that identifies a winner with precision.


Design a game played on a $10 \times 10$ board where players move from square 1 to 100 based on dice rolls, while navigating obstacles (snakes) and shortcuts (ladders).

Functional Requirements:

  • Board Setup: Initialize a 100-square grid with configurable snakes and ladders.
  • Turn Logic: Support 2+ players taking turns in a fixed sequence.
  • Dice Mechanics: Simulate a 1-6 die roll. A roll of ‘6’ grants an extra turn.
  • Movement Rules: Handle snake bites (move down) and ladder climbs (move up).
  • Winning Condition: A player wins by landing exactly on square 100.
  • Multiple Occupancy: Allow any number of players on the same square.

Non-Functional Requirements:

  • Extensibility: Allow changing board size or adding new entities easily.
  • Clean Output: Provide a clear log of moves and game events.
  • Robustness: Prevent invalid moves (e.g., rolling a 5 at square 98).

The system coordinates between the Game controller, the Board, the Dice, and the Players.

Diagram
classDiagram
    class Game {
        -Board board
        -Dice dice
        -Queue~Player~ players
        -GameStatus status
        +play()
        -takeTurn(player)
    }
    
    class Board {
        -int size
        -Map~int, BoardEntity~ entities
        +getFinalPosition(pos)
    }
    
    class BoardEntity {
        <<abstract>>
        -int start
        -int end
        +action(pos)*
    }

    class Snake {
        +action()
    }

    class Player {
        -String name
        -int currentPos
    }

    Game --> Board
    Game --> Dice
    Board *-- BoardEntity
    BoardEntity <|-- Snake
    BoardEntity <|-- Ladder

Diagram

Snakes and ladders are essentially the same: they take you from $A$ to $B$. One goes up, one goes down.

Solution: Use Inheritance. Create an abstract BoardEntity class with start and end fields. Snake and Ladder inherit from this. The Board can then store a Map<Integer, BoardEntity>, allowing for $O(1)$ lookups to see if a square has an obstacle.

Managing who goes next can be tricky, especially when a ‘6’ grants an extra turn.

Solution: Use a Queue Data Structure. The Game class stores players in a queue. Every turn, you poll() the player, process their move, and then add() them back to the end of the queue. If they roll a ‘6’, you just process another turn before re-queuing them.

A player must land exactly on 100. If they are at 98 and roll a 5, they should not move.

Solution: Implement Boundary Validation in the movement logic. Before updating the player’s currentPos, calculate the potential newPos. If newPos > board.size, return the original position, effectively skipping the movement part of the turn.


By solving this problem, you’ll master:

  • Queue-based Logic - Managing sequential access to resources.
  • State Transitions - Handling game phases and win conditions.
  • OOP Abstraction - Using inheritance to simplify complex entities.
  • Randomization Handling - Decoupling core logic from stochastic inputs.

Ready to see the full implementation? Open the interactive playground to access:

  • 🎯 Step-by-step guidance through the 8-step LLD approach
  • 📊 Interactive UML builder to visualize your design
  • 💻 Complete Code Solutions in Python, Java, C++, TypeScript, JavaScript, C#
  • 🤖 AI-powered review of your design and code

After mastering Snake and Ladder, try these similar problems: