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.
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:
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.
Hitting and Entering
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)
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 ).
Note:-
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.
The goal of this assignment is to create an image of a backgammon board, patterned carefully...
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 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 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 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 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...