Welcome to the Snake and Ladders game! Refer to this article: Enhancing a Classic: Design Patterns in Snake & Ladders
This project implements the classic board game of Snake and Ladders in Java. It demonstrates various programming concepts and potential design patterns.
The GameEventListener interface and its implementations allow for decoupled communication between the Game class and other components that want to be notified of game events (dice rolls, player movements, game over).
This pattern is used to create different types of game boards and dice.
This pattern is implemented for different dice rolling mechanisms (e.g., fair dice, custom dice).
- Create a board with classic config or a desired size (number of squares) and configure snake and ladder positions.
- Choose 1 when asked to choose board configuration to use classic configurations.
- Choose 2 to add custom configurations for a board.
- Define players.
- Enter number of players.
- Keep on adding names for the players.
- Optionally, create and register custom listeners implementing GameEventListener to receive game event notifications.
Players take turns rolling a die. The player moves their piece forward the number of spaces indicated by the die roll. If the player lands on the head of a ladder, they climb up to the ladder's top square. If the player lands on the head of a snake, they slide down to the snake's tail square. The first player to reach the final square (the last square of board) wins the game.
- Ensure you have Java installed on your system.
- Clone or download the project repository.
- Run
SnakeAndLadders.java