Case Study59 Board Game: Diamonds

Board Game: Diamonds

Problem Description

The aim of this project is to build a simple board game called “Diamonds.” Developing this game will enhance students’ ability to program using Visual Basic for Excel. The game is played with two players or a player and a computer. The student should develop an algorithm, based on the game logic described below, to generate computer moves when the game is played between a player and the computer.

The game is usually played in a 10 by 6 playing board. To play the game, the players need 12 tokens (six tokens per player, and the tokens are numbered 1 through 6), 48 diamonds, and two dice. The first die has six sides, each one numbered (1 through 6). The other (called the Piece die) has its six sides labeled as Pawn, King, Queen, Horse, Bishop, and Castle.

The game starts with the following set-up of the board: each player places tokens in the first row of the player’s side in a random way, and the 48 diamonds are set (one on each square) on the board. The players take turns in playing the game. On the player’s turn, the player throws the two dice. The numbered die shows which of the (numbered) tokens will be moving; the Piece die shows what type of movement should be made (below we present all the possible movements). Then, the player lands one of the tokens on a square that could be empty or occupied by a diamond or the other player’s token. If the square is already occupied by a token/diamond, the player collects the token/diamond from the square and sets there the player’s own token. The first player to collect 25 diamonds wins the game. If both players collect 24 diamonds, the game is a tie. The maximum number of tokens that a player can capture from the opponent is five.

During the course of the game, if a player rolls the dice and the number that rolls up is a number depicting a token that has been collected by the opponent, then the player does not get to move on that turn. It is then the opponent’s turn to roll the dice for a move.

Token Movements

The following are the types of movements a player can make. The movements depend on the letter shown when the Piece die is thrown.

  1. Pawn: the player moves one square at a time forward, backward, or diagonally.
  2. King: the player moves one square at a time horizontally, vertically, or diagonally.
  3. Queen: the player moves forward, backward, horizontally, vertically, or diagonally up to the length or width of the playing board for as long as it is a straight run without any diamonds or tokens between the start and the finish of the move.
  4. Castle: the player moves forward, backward, horizontally, or vertically up to the length or width of the playing board for as long as it is a straight run without any diamonds or tokens between the start and the finish of the move.
  5. Bishop: the player moves forward, backward, or diagonally up to the length or width of the playing board for as long as it is a straight run without any diamonds or tokens between the start and the finish of the move.
  6. Horse: the player moves in any "L" shape on the playing board. A horse can either move one square up/down and two squares to the right/left; or two squares up/down and one square to the right/left; or one square to the right/left and two squares up/down; or two squares to the right/left and one square up/down. A horse may jump over other tokens and diamonds during a move in order to land on an empty square or to capture a token/diamond.

User Interface

  1. Build the welcome form.
  2. Build a form that includes the following items:
  3. Build a 10 by 6 play board in an Excel spreadsheet. The slots/cells of the play board should be squared. A snapshot of the board is given below.

  1. Insert a combo box that allows the player(s) to pick a color for the board.
  2. Insert a combo box that allows the player(s) to pick a color and a shape for the diamonds. For example, in the play board presented above the diamonds are presented by small black circles.
  3. Insert a combo box that allows the player(s) to pick a color and a shape for the tokens. For example, in the play board presented above, the tokens are presented with large black/white circles.
  4. Insert a combo box that allows the player to choose whether the game will be played between the player and the computer or between two players. Upon submission of this information, text boxes appear for the player(s) to type in the name(s).
  5. Insert a combo box that allows the players to choose who will start the game.
  6. Insert a command button named “Play.”
  7. If it is the player’s turn, when the player clicks on the “Play” button, the Visual Basic code randomly generates an integer from 1 to 6 and randomly picks one of the following six letters: P, K, Q, C, B, or H. The player then makes a move (uses the mouse to move a token) based on the number and letter received from tossing the dice. An error message should appear if the player makes an illegal move.
  8. If it is the computer’s turn to play, an integer from 1 to 6 is randomly generated and one of the following six letters, P, K, Q, C, B, or H, is randomly picked. A move (of the computer’s token) is made based on the number and letter received from tossing the dice. When programming the moves of the computer, give priority to moves that collect tokens/diamonds.
  9. Insert text boxes that present the following: the total number of moves for each player, the total number of diamonds and tokens collected, and the name of the player who should play next.
  10. Display a message box that presents the name of the winner, the total number of moves, and the total number of diamonds and tokens collected when the game is over. Note that the game is over if we have a winner (one of the players collected 25 diamonds) or if we have a tie (each player collected 24 diamonds).
  11. Insert a command button that allows the player to choose whether to replay the game or close the program.

Design a logo for this project. Insert this logo in the forms created above. Pick a background color and a font color for the forms created. Include the following in the forms created: record navigation command buttons, record operations command buttons, and form operations command buttons as needed.

Reports

Report the following information about the games played so far: the names of the players, the name of the winner, the total number of tokens/diamonds collected by each player, and the total number of moves.