Case Study 59
59
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.
a.
Pawn: the player moves one square at a time forward, backward, or diagonally.
b.
King: the player moves one square at a time horizontally, vertically, or diagonally.
c.
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.
d.
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.
e.
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.
f.
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;
Case Study 59
Board Game: Diamonds
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:
a.
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.
b.
Insert a combo box that allows the player(s) to pick a color for the board.
c.
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.
d.
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.
e.
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).
f.
Insert a combo box that allows the players to choose who will start the game.
g.
Insert a command button named “Play.”
i.
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
K T
K T
K T
k 1t 1
k 1t 1
k 1t 1
min : ckt xkt hkt I kt Fkt z kt
Case Study 59
Subject to :
K
zkt 1
Board Game: Diamonds
letter
for t 1,...,
T , received from tossing
(1) the dice. An error message should appear if the
player makes an illegal move.
k 1
xkt I k ,t 1 I kt d kt
xkt Pkt z kt
forii.k 1If,...,
1,...,
T,
(2turn
)
it K
is; tthe
computer’s
to play, an integer from 1 to 6 is randomly
for k 1generated
,..., K ; t 1and
,..., Tone
, of(3the
) 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
xkt , I kt 0
for k 1number
,..., K ; t and
1,...,
T , received
(4) from tossing the dice. When programming the
letter
for k 1moves
,..., K ; tofthe
1,...,
T.
(5give
) priority to moves that collect tokens/diamonds.
computer,
z kt {0,1}
h.
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.
i.
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).
j.
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.
© Copyright 2026 Paperzz