This is a simple implementation of the classic Snake and Ladder game using Java. Two players roll a dice and move across the board, encountering snakes and ladders along the way, aiming to reach the 100th square.
The Snake and Ladder game simulates two players taking turns to roll a dice. The game board contains specific positions that either help the player progress (ladders) or send them back (snakes). The first player to reach square 100 wins the game.
- Two players take turns rolling a dice.
- The game features multiple snakes and ladders which alter the player's position.
- The game automatically checks if a player encounters a snake or a ladder.
- The game continues until one player reaches 100.
- Two players roll the dice on each turn.
- If the player's position after rolling the dice is less than or equal to 100, they can move.
- If a player lands on a snake or ladder, their position is updated accordingly.
- The game continues until one player reaches exactly 100, at which point they win.
To run the game, ensure you have Java installed. Follow these steps:
-
Clone or download the repository.
git clone https://github.com/yourusername/snake-ladder-java.git
-
Navigate to the project folder and compile the Java file.
cd snake-ladder-java javac SnakeLadder.java -
Run the program.
java SnakeLadder
-
The game will run in the terminal, showing the progress of both players and the final winner.
- The board consists of 100 squares.
- Players start at square 0.
- Players take turns to roll a dice (with values between 1 and 6).
- If a player lands on a ladder, they move forward to a higher number.
- If a player lands on a snake, they move backward to a lower number.
- The first player to reach square 100 wins.
-
Ladders:
- Square 2 -> 38
- Square 9 -> 14
- Square 15 -> 82
- Square 16 -> 54
- Square 50 -> 91
- Square 74 -> 87
-
Snakes:
- Square 18 -> 6
- Square 24 -> 7
- Square 61 -> 16
- Square 72 -> 47
- Square 96 -> 76