logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Debra StephensonBusiness
(5/5)

852 Answers

Hire Me
expert
Barbara ElseMathematics
(5/5)

706 Answers

Hire Me
expert
usman NasirAccounting
(/5)

992 Answers

Hire Me
expert
Andrea LiguoriLaw
(5/5)

988 Answers

Hire Me
Python Programming

The objective of this project is to design the Snakes and Ladders game. The project needs to simulate the game with the ability to roll dice between two players, and then apply the game logic to decide who the winner

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Programming Project

The objective of this project is to design the Snakes and Ladders game. The project needs to simulate the game with the ability to roll dice between two players, and then apply the game logic to decide who the winner is.

The game board has 100 cells starting from 1 to 100. There are two players and each player rolls the dice and moves cell position accordingly. There are snakes and ladders in different cells with each cell having either a ladder, a snake or nothing but not both in the same cell. If a player moves to a cell that contains a ladder, the player jumps up by 15 cells. If the player moves to a cell including a snake mouth, the player drops off by 10 cells. The rolling of dice continues until one of the players reaches a cell above 99, that player will be declared as the winner of the game.

The steps to design the game are:

Step 1: get_players_list()

Create a function get_players_list() that reads and stores both player names in a list. The function prints and returns name_list.

 

Step 2: generate_ladders_position()

There are 15 ladders in the game. Declare function generate_ladders_position()to generate the positions of these ladders randomly, and store them in a list. Ladder positions should be in the range of cells 5 to 85 (both inclusive). You must avoid assigning the same cell to more than one ladder. The function prints the ladder positions and returns ladders_list. 

 

Step 3: generate_snakes_position()

There are 10 snakes in the game. Declare function generate_snakes_position()to generate the positions of these snakes mouths randomly, and store them in a list. Snake mouth positions should be in the range of cells 20 to 95 (both inclusive).

You must avoid assigning the same cell to more than one snake. Moreover, the function should receive an input argument (ladders_list) to avoid assigning a cell to both a ladder or a snake, meaning that no cell can host both a ladder or a snake mouth. Nevertheless, for simplicity reasons, the game allows snakes cells that jump down to a ladder cell, or ladder cells that put the player in a snake mouth. For example, a player may jump on a ladder and then get bitten by a snake.

The function prints and returns the snakes_list. 

 

Step 4: roll_dice()

Define a function to roll the dice i.e., generating a random number between 1 and 6 (both inclusive). The function should receive two arguments, current_position (an integer) of the player rolling the dice, and player_name, the name of the player rolling the dice. The function returns the new position of the player. The function also prints the value of the dice, and the new position of the player. The new position is calculated as current_position + the dice value.

For example, roll_dice(current_position=54, player_name="John") prints:

Step 5: check_for_ladder()

Write a function to accept three input arguments, 1) current_position of a player, 2)ladder_list, and 3) plyer_name. The function checks if the position contains a ladder. If so, increase the current position of the player by 15 cells and return the new position.

The function also prints a message explaining what happened, and the player’s new position. For example:

Step 6: check_for_snake()

Create a function to receive three input arguments, 1) current_position of the player, 2) snake_list, and 3) player_name, and check if the position contains a snake mouth. If so, decrease the current position of the player by 10 cells and return the new position.

The function also prints a message explaining what happened, and the player’s new position, for example:

Step 7: Main Program

The main program is responsible for running the game using the functions defined above, and identify the winner. An example of the tasks on the Main program can be:

  1. Decalre players_positions list to maintain the position of the players, each index shows the position of a player. Initialize each index of the list by zero meaning that the initial position of each player is cell 0.
  2. Initialize the list of players by calling get_players_list() and store it in players_name
  3. Initialize list of ladders and snakes by calling the generate_ladders_position() and generate_snakes_position() and store them into two lists respectively, ladders_list and snakes_list.
  4. Use a while loop to start playing the game. This loop iterates as long as both of player_positions are less than 99 (99 exclusive):
    • Use an inner for loop that counts twice, once for each player:
      1. Get new position of the current player by calling roll_dice().
      2. Check whether the player position is more than 99 (99 exclusive). In this case, the player is the winner of the game so the game should print a message and exit the program by breaking the loop.
  • Otherwise, for the current player, check for ladder and snake positions by calling check_for_ladder() and check_for_snakes(), and update the current player’s position respectively, if necessary.

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme