Machine Coding Question: Design Snake & Ladder
Design and implement a multiplayer Snake & Ladder game — authentication, board setup, dice-based turns, win detection, and multi-board bonus features.
Design and implement a Snake & Ladder game where multiple logged-in players take turns rolling a dice, climbing ladders, sliding down snakes, and racing to be the first to reach the final cell.
This one tests whether you can model a randomized board (snake and ladder placement) cleanly, handle turn-based multiplayer state, and keep the movement and win logic correct as you layer on dice variants and multiple simultaneous games.
Objective
The primary objective of this project is to design and implement a Snake & Ladder game on an n x n board that supports authenticated multiplayer sessions, randomized (or custom) snake and ladder placement, dice-based turns, and correct win detection when a player reaches the final cell exactly.
Functional Requirements
Requirements are split into three tiers so you know what to prioritize under time pressure: build first, build if time allows, and discuss only.
Part 1 — Basic Requirements
Core functionality you must build and get working first.
1. User Authentication
2. Game Setup
3. Rules
At present, player movement is based on the total sum of the dice values. For example, a roll of [6, 2] results in a single move of 6 + 2 = 8 steps forward.
4. Additional Assumptions
Part 2 — Bonus Features
Extensibility checks — can your design support multiple simultaneous boards, alternate dice rules, and custom setups without a rewrite.
Part 3 — Future Enhancements
Discuss-only evolution — how the system could grow next.
Example Usage: Full Walkthrough
Here's how a sample playthrough runs end-to-end, one step at a time.
1. Log in
🟢 Welcome to Snake & Ladder Game 🐍🪜
🔐 Please log in to continue.
> Username: alice
> Password: *****
✅ Login successful. Welcome, Alice!
> Username: bob
> Password: *****
✅ Login successful. Welcome, Bob!
2. Create the game and initialize the board
🎮 Step 1: Create Game
> Creating a new Snake & Ladder game with board size 10x10...
> Game initialized with 6 snakes and 6 ladders.
🐍 Snake Positions:
- Head at 99 → Tail at 54
- Head at 87 → Tail at 24
- Head at 62 → Tail at 19
- Head at 48 → Tail at 26
- Head at 36 → Tail at 6
- Head at 32 → Tail at 10
🪜 Ladder Positions:
- Start at 3 → End at 22
- Start at 5 → End at 8
- Start at 11 → End at 26
- Start at 20 → End at 29
- Start at 27 → End at 84
- Start at 40 → End at 59
3. Add players
👥 Step 2: Add Players
> Adding player: Alice
> Adding player: Bob
✅ All players added. Ready to play!
4. Play through turns
🟢 Game Start!
-----------------------------------
🎲 Turn 1:
Alice rolls the dice... 🎲 4
Alice moves from 0 to 4
Bob rolls the dice... 🎲 6
Bob moves from 0 to 6
-----------------------------------
🎲 Turn 2:
Alice rolls the dice... 🎲 1
Alice moves from 4 to 5
🚀 Alice found a ladder! Climbs up to 8
Bob rolls the dice... 🎲 2
Bob moves from 6 to 8
-----------------------------------
🎲 Turn 3:
Alice rolls the dice... 🎲 3
Alice moves from 8 to 11
🚀 Alice found a ladder! Climbs up to 26
Bob rolls the dice... 🎲 6
Bob moves from 8 to 14
-----------------------------------
🎲 Turn 4:
Alice rolls the dice... 🎲 1
Alice moves from 26 to 27
🚀 Alice found a ladder! Climbs up to 84
Bob rolls the dice... 🎲 5
Bob moves from 14 to 19
...
5. A player reaches 100 and wins
🎉 Alice rolls a 2 and lands on 100!
🎊 Alice wins the game! 🏆
Game Over.
🔚 Bob has left the game.
Thank you for playing!
Alice reaches exactly 100 via a run of ladder climbs and wins the game. Bob remains one move behind when the game ends, and the session closes cleanly once a winner is declared.