dcsimg
Results 1 to 7 of 7

Thread: Snakes and ladders game, URGENT help needed

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2017
    Posts
    7

    Exclamation Snakes and ladders game, URGENT help needed

    Can anybody PLEASE be a complete life saver and code this for me? I'm desperate. This is the task description.
    TASK
    A manufacturer of games has decided to design a new snakes and ladders board consisting of 100 squares. The manufacturer has asked the systems analyst to design a simulation of the game. The systems analyst has been told that:
    • There must be exactly 10 snakes and 10 ladders.
    • The number of squares that a snake sends a player back must lie between 10 and 30.
    • The number of squares that a ladder sends a player forward must lie between 10 and 30.

    The systems analyst has decided to represent the board by using a one-dimensional array with 100 cells. Initially each cell is to be set to zero.

    When the game starts the user is asked to input the positions of the snakes. This is to be done by entering, for each snake, the square on which its head is to be and the number of squares a player must go back when landing on a snake’s head. For each snake, the number of squares to go back is then to be stored in the cell representing the head of the snake, as a negative integer.

    This is repeated for the ladders by inputting the squares for the feet of the ladders and the number of squares a player must go forward when landing on the foot of a ladder. For each ladder, the number of squares to go forward should be stored as a positive integer in the cell representing the foot of the ladder.

    Part of the array may look similar to the extract below. This indicates that there is a snake’s head in cell 51 and its tail is in cell 41. The bottom of a ladder is in cell 40 and its top is in cell 52. The remaining squares do not contain any snakes or ladders.
    Name:  rray.jpg
Views: 89
Size:  8.6 KB
    You should annotate all your code and use meaningful names throughout.
    (a)
    Create annotated code that initialises the board ready for the user input. [2]

    (b)
    Create an interface that allows the user to input the data as described above. Your code should validate the input and store the data as described above. You need only check for values that satisfy the criteria given above. [5]

    The rules of this game of Snakes and Ladders are:
    • On each turn, a player moves forward the number of squares shown when a 6-sided die is thrown.
    • If a player lands on the head of a snake, the player must move to the tail of the snake.
    • If a player lands on the foot of a ladder, the player must move to the top of the ladder.
    • If a move would result in the player going off the board, no move is made.

    You need only simulate the moves of a single player.

    (c)
    Create annotated code that simulates a game of snakes and ladders. [8]
    Attached Images Attached Images  

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,657

    Re: Snakes and ladders game, URGENT help needed

    You said this thread was resolved.
    What happened?

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2017
    Posts
    7

    Re: Snakes and ladders game, URGENT help needed

    i was trying to delete the previous thread and i didnt know how to

  4. #4
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,657

    Re: Snakes and ladders game, URGENT help needed

    Probably not much has changed. As easy as it is, most people will not likely do your assignment for you. You should be aware that it is cheating.

  5. #5
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,657

    Re: Snakes and ladders game, URGENT help needed

    Have you tried to outline the tasks of how you want to implement the game.
    Depending on the complexity, I do like to write out the logic and order in simple terms and steps, and then it should be easier to work on turning each step into code.
    For instance, the directions tell you how to implement the core structures, how many snakes, and how many ladders, and in what order to do the setup. So, write those down and decide how you want to implement them. This should be easy to do with a simple console based program.
    With a bit more complication, you could do it with a Graphical User Interface (GUI). It could be basic controls, such as a list box with 100 items in it initially set to 0 representing your array. Perhaps have two columns, so you can display the square number (1 to 100) and the value stored at each location (initially all zeros) and then 10 negative number the user specifies for the snakes (at the square index 1 to 100, and the value -10 to -30), and then 10 positive numbers for the ladders at the offset (1 to 100) and value range is 10 to 30.
    You just need to check the square they specify (1 to 100) is 0 before changing it. And also verify that the value they specify is in the appropriate range.
    It looks like you don't even have to check if the value of the range the user specifies is within the range of the board during input, so that saves you some work.
    You just have to ignore the snake or ladder when you move if the square you would move to is less than the first square or greater than the last square, i.e. a ladder can't take you off the board to win, and a snake can take you off the board at the bottom. You just don't move in those conditions (ignore the snake and ladder). It is a later exercise to limit the snake and ladder sizes to be within the board, for example since the size is a minimum of 10, you can't have a snake within the first 9 positions of the game, and you can't have a ladder in the last 9 positions of the game. Likewise you can't have a -30 size snake in the first 29 positions of the board or a 30 size ladder in the last 29.

    The main question I have it how the game ends. The specification doesn't mention whether the game is over when your roll takes you to the last square or beyond. If you had a snake head on the last square, then you definitely would have to roll past that to win the game. So, even if there was not a snake on the last square and you landed on it, I presume you haven't won the game until your next roll takes you off the board.
    A ladder can't take you off the board, but you do go off the board on a roll. That is the only thing that makes sense to me, for the conditions given.
    Last edited by passel; Dec 14th, 2017 at 04:50 PM.

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,755

    Re: Snakes and ladders game, URGENT help needed

    The original question was asked a month ago. Has nothing changed?
    My usual boring signature: Nothing

  7. #7
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,580

    Re: Snakes and ladders game, URGENT help needed

    What have you been doing for a month?

    Have you even implemented the thing I spent 2 hours writing for you? Prove it to me.

    If you haven't implemented it, or you didn't try, what exactly makes you think I'm going to risk another 2 hours on you?

    I'm not doing squat until you read my post #7 and finish it by addressing the bullet list at the end. I will answer questions about #7, but nothing else, until I'm satisfied you've made my previous work worth it. If someone else wants to help you out, that's their prerogative, but I feel very disrespected and used.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width