Low LeveL Design of Snakes and Ladders

ยท

2 min read

Requirements

  • The number of snakes and ladders must be configurable

  • The number of dice simultaneously thrown is configurable (default 1)

Components:

  1. Game Board: The game board consists of a grid with numbered squares, typically 10x10. The first square is numbered 1, and the last square is the winning square, usually 100.

  2. Players: The game can be played with two or more players.

  3. Dice: You need a standard six-sided die to determine how many squares a player can move on their turn.

Gameplay:

  1. Players take turns in a clockwise order.

  2. On a player's turn, they roll the dice and move their game piece (usually represented by a token) forward the number of squares/cells indicated by the dice.

  3. If a player lands on a square with the base of a ladder, they move their piece to the square at the top of the ladder.

  4. If a player lands on a square with the head of a snake, they move their piece to the square at the tail of the snake.

  5. The game continues until one of the players reaches or exceeds the winning square (usually 100). That player is declared the winner.

Special Rule:

  • A player must roll the exact number to reach the winning square. For example, if a player is on square 98 and rolls a 3, they cannot move to square 101; they must wait for their next turn.

UML

  • The GameManager initialises the game by setting up the board Size, number of players, Dice (composite design pattern) and number of snakes and ladders

  • We can combine Snakes and Ladder objects into a singular object called Jump as they have the same attributes and the only difference is that a snake jump will take you backwards and a ladder jump will take you towards 100

  • The game board initialises cells of the board, sets jumps if any

Code

to be updated ...

ย