logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

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.
(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. 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. The LineItem class will represent an individual

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

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

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

expert
Um e HaniScience

538 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

570 Answers

Hire Me
expert
Husnain SaeedComputer science

770 Answers

Hire Me
expert
Atharva PatilComputer science

549 Answers

Hire Me

Get Free Quote!

283 Experts Online