Snakes and Ladders using Python

Snakes and ladders is a board game for two or more players and is played worldwide. It originated in ancient India as “Moksha Patam”, and was brought to the UK in the 1890s. It is a race game where each player progresses through the 100 numbered cells of the board by rolling a dice. When a player lands at the bottom of the ladder, they can automatically move their token to the top of the ladder. However, when a player lands in the mouth of a snake, they slide down to the tail of the snake.
Snakes and Ladders
The first player to reach the last cell of the board (cell 100), they win. However they have to land exactly on this cell. If they reach a number higher than 100, then their token bounce back. For instance, if a player is on cell 98 and rolls a 6, they move as follows: 98 >> 99 >> 100 >> 99 >> 98 >> 97 >> 96.

Another rule is that when a player rolls a 6, they can have another turn.

We have started to implement the game using Python code. However our code is incomplete. For instance, we our game is only for one player. We dd not implement all the ladders and snakes of the board. And we did not check if the player is allowed another go (when rolling a 6).

After checking and testing the code provided below, you will need to complete 3 tasks to finalise this code:

    Add some Python code (from line 55) to make sure all ladders and snakes are catered for.
    Add some Python code to allow the player to have another go when they roll a 6.
    Add some Python code to allow add a second player to the game.

Python code so far…

unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 4.1 / 5. Vote count: 37

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!