Question

The goal of this assignment is to create an image of a backgammon board, patterned carefully...

The goal of this assignment is to create an image of a backgammon board, patterned carefully after the following model (click on image to zoom):

Backgammon is a two-player game played on a board with 24 triangles known as points. Each player starts with 15 checkers, with an initial configuration as shown above. The points alternate in color as you go around the board, and there is a clear top-to-bottom symmetry to the placement of the checkers.

We have chosen this assignment as a way to exercise your use of control structures. Although the board is fixed and finite, and you could presumably create the image above by manually configuring the geometry for 24 different triangles, 30 circles, 24 text labels, and so on, you will only receive significant credit if you use control structures to express these patterns. As a general rule, if you ever find yourself "copying-and-pasting" code from one part of a program to another, there should be a more elegant way to express the repetition and variation.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

Backgammon is a two player game played on a board consisting of 24 narrow triangles called points. The triangles alternate in color and are grouped into four quadrants of six triangles each. The quadrants are referred to as a player's home board and outer board, and the opponent's home board and outer board. The home and outer boards are separated from each other by a ridge down the center of the board called the bar.Each point is numbered as shown in the figure below

The bottom right point starts with 1 and increases left-ward. The top-right point is numbered 24. Each player has fifteen checkers of his own color. The initial arrangement of checkers is:

  • For the 1st player, 2 on first point, 5 on twelve and ninteen point, and 3 on seventeen point.
  • For the 2nd player, 2 on twenty-fourth point, 5 on thirteen and sixth point, and 3 on eigth point.

In this game, there is no doubling cube and white always goes first. Two games are played with each player playing as white once.

The objective of the game is move all your checkers into your own home board and then bear them off. The first player to bear off all of their checkers wins the game.

Movement of Checkers

Each player is allowed to roll two 6 sided dice. The points on the dice indicates the total number of triangles a player can move his checkers. A checker can always be moved close to its home board and not away from it. A checker movement has the following rules.

  • A checker can move only to an open point. An open point is defined as a point which has checkers of the same player or less than 2 checkers of the opponent.
  • If a player rolls a 4, 6, then he may move one checker 4 spaces to an open point and another checker 6 spaces to an open point. Or move one checker a total of 10 spaces such that the intermediate point (4th or the 6th space) is open.
  • If a player rolls a double ( both dices having the same number ), he gets to play the number rolled on the dice twice in whatever combination he chooses to.
  • A player must use all the numbers rolled by the dice if its legally possible. If only 1 number is possible, that number must be played.
  • If no dice rolls are possible, the move is automatically skipped.

Hitting and Entering

  • A point occupied by only 1 checker of either color is called a blot. If an opponent's coin is placed on the same point, then its called a hit and the existing checker is moved to the bar.
  • If a player has one or more checkers of his on the bar, his immediate objective is to enter his checkers into the opponent's home board (1-6) for the 1st player and (19-24) for the 2nd player.
  • The movement follows the same rules as regular movement of checkers. A checker can be placed on open points only.
  • No other moves are possible until all the checkers are removed from the bar.
  • A player looses his turn if neither of the points are open.
  • After the last checker from the bar has entered the board, unused moves can be played in a regular manner.

Bearing Off

Once a player has moved all his checkers into his home board, he can start bearing off. The bear off points for the 1st player and the 2nd player is 25 and 0 respectively.

A player bears off a checker by rolling a number that corresponds to the point on which the checker resides, and then removing that checker from the board. Thus, rolling a 6 permits the player to remove a checker from the six (19th point for the first player) point. If there is no checker on the point indicated by the roll, the player must make a legal move using a checker on a higher-numbered point. If there are no checkers on higher-numbered points, the player is permitted (and required) to remove a checker from the highest point on which one of his checkers resides. A player is under no obligation to bear off if he can make an otherwise legal move.

A player must have all of his active checkers in his home board in order to bear off. If a checker is hit during the bear-off process, the player must bring that checker back to his home board before continuing to bear off. The first player to bear off all fifteen checkers wins the game.

Input Format

The first line of the input is 1 or 2 indicating its either white or black who is playing the game. 26 lines follow. Each line contains 1 or 2 integers ( separated by a single space ) indicating the number of checkers on the point and the type of the checker ( 1 for 1st player's checker and 2 for 2nd player's checker)

  • 5 1 indicates that there are 5 checkers of the first player.
  • 6 2 indicates that there are 6 checkers of the second player.
  • 0 indicates that the point has no checkers. The first and the last line are bear off points for 2nd player and the 1st player respectively.

2 lines follow each line indicating the number of coins in the bar for the 1st player and the 2nd player.
The next line contains an integer ( 2 or 4 ) indicating the number of dice rolls played on behalf of player by the computer. 4 both the dice rolled the same number. 2 or 4 lines follow each indicating a number between 1-6 which is the number on the dice.

Output Format

For every possible legal dice roll possible, print a checker move in a new line. Each move has two integers ( start point and end point ).

  • 1 2 a checker is moved from 1 to 2.
  • -1 5 a checker is removed from the bar and is placed at 5 on a dice roll of 5.
  • 1 0 a coin is being bared off.

Note:-

  • player 1 moves his checkers from 1 to 24 and later to 25 for bearing off.
  • player 2 moves his checkers from 24 to 1 and later to 0 for bearing off.
  • player 1 removes his checkers from bar and places it on the points between 1 to 6.
  • player 2 removes his checkers from bar and places it on the points between 19 to 24. A dice roll of 1 would place a checker for player 2 from bar to 24, a dice roll of 2 would place it on 23 and so on.

If your code has an input, it is guaranteed that atleast 1 dice roll is legally possible.

Sample Input

1
0
2 1
0
0
0
0
5 2
0
3 2
0
0
0
5 1
5 2
0
0
0
3 1
0
5 1
0
0
0
0
2 2
0
0
0
2
5
4

Sample Output

1 5
12 17

Explanation

Here dice roll is 5, 4. 1st player moves his checker from 1 to 5 and another from 12 to 17.

Add a comment
Know the answer?
Add Answer to:
The goal of this assignment is to create an image of a backgammon board, patterned carefully...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For this assignment, your job is to create a simple game called Opoly. The objectives of...

    For this assignment, your job is to create a simple game called Opoly. The objectives of this assignment are to: Break down a problem into smaller, easier problems. Write Java methods that call upon other methods to accomplish tasks. Use a seed value to generate random a sequence of random numbers. Learn the coding practice of writing methods that perform a specific task. Opoly works this way: The board is a circular track of variable length (the user determines the...

  • For your Project, you will develop a simple battleship game. Battleship is a guessing game for...

    For your Project, you will develop a simple battleship game. Battleship is a guessing game for two players. It is played on four grids. Two grids (one for each player) are used to mark each players' fleets of ships (including battleships). The locations of the fleet (these first two grids) are concealed from the other player so that they do not know the locations of the opponent’s ships. Players alternate turns by ‘firing torpedoes’ at the other player's ships. The...

  • I need help with my very last assignment of this term PLEASE!!, and here are the instructions: After reading Chapter T...

    I need help with my very last assignment of this term PLEASE!!, and here are the instructions: After reading Chapter Two, “Keys to Successful IT Governance,” from Roger Kroft and Guy Scalzi’s book entitled, IT Governance in Hospitals and Health Systems, please refer to the following assignment instructions below. This chapter consists of interviews with executives identifying mistakes that are made when governing healthcare information technology (IT). The chapter is broken down into subheadings listing areas of importance to understand...

  • Hi, Kindly assist with my project management assignment below using the attached case study Question 1 Update the project charter for the remainder of the project in response to Adams’ memo (lines 241...

    Hi, Kindly assist with my project management assignment below using the attached case study Question 1 Update the project charter for the remainder of the project in response to Adams’ memo (lines 241 through 246). Question 2 Prepare a plan for the remainder of the project in response to Adams’ memo (lines 241 through 246). Your answers to the above will be assessed in terms of the level of communication displayed, the insights and inferences drawn, and your ability to...

  • CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a...

    CASE 20 Enron: Not Accounting for the Future* INTRODUCTION Once upon a time, there was a gleaming office tower in Houston, Texas. In front of that gleaming tower was a giant "E" slowly revolving, flashing in the hot Texas sun. But in 2001, the Enron Corporation, which once ranked among the top Fortune 500 companies, would collapse under a mountain of debt that had been concealed through a complex scheme of off-balance-sheet partnerships. Forced to declare bankruptcy, the energy firm...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT