Snake and Ladder
Design a snake and ladder game with a pluggable dice, a jump map for snakes and ladders, and a players queue.
Requirements
Snake and ladder is a good machine-coding round problem because the rules are simple and the design choices are visible. Ask before you code.
Clarifying questions:
- How big is the board? (Usually 100 cells, numbered 1 to 100. Make it a parameter.)
- How many players, and in what order? (Two or more, fixed order.)
- How many dice and how many faces? (One die, six faces, but design for change.)
- What happens if a roll goes past the last cell? (Common rule: the player stays where they are. Ask.)
- Does a 6 give an extra turn? (Common house rule. Treat it as an extension.)
- Can a ladder end on a snake head, or two jumps share a cell? (No: reject such boards.)
Scope for this lesson:
- A board of
sizecells with a map of snakes and ladders. - Players start off the board at position 0 and move in turn order.
- The first player to land exactly on the last cell wins.
- A roll that would overshoot is ignored.
- The dice is replaceable, so the game can be tested.
Out of scope: a UI, money, multiple winners (ranking), saving a game.
1 of 10