Expert Work - Write a VBA Sub Program

Expert Work - Write a VBA Sub Program

 1. Please choose ONE of the following four problems (board games) and program it in Visual Basic with or without using user Forms. The game could be entirely using Excel or user Forms. Along with the Excel sheet, also write a memo explaining the purpose of the program, approach taken, and solution of the problem.

Chutes & Ladders:

Write a VBA Sub Program to create the snakes and ladders game for two players. The player who reaches the 100 th square wins the game. Listed below are the rules that you need to keep in mind while building the game:

a. Create a 10 X 10 board and place the snakes and ladders as shown above.

b. Player one will start the game by rolling the die, which is a randomly generate number between 1 and 6. Player 1 should advance his/her token the rolled numbe of spaces. Similarly player two takes his/her turn. Players should alternate their turns.

c. If a player’s token lands on the lower-­­numbered end of a ladder, the player moves the token up to the ladder’s higher-­­numbered square. If the player lands on the higher-­­numbered square of a snake, the token is moved down to the snake’s lower-­­ numbered square.

d. The player who first reaches the 100 th square is declared the winner.

The green arrow represents the ladders, and the red arrow represents the snakes. Forexample, if a player’s token lands on 18, the player should move up his/her token to 44. If player’s token lands on 32, the player should move his/her token down to 11.

 b. Fox & Hounds

Fox and Hounds [2] is a board game for two players, where one player controls the fox antries to evade the hounds and the other player directs four hounds and attempts to trap thfox. Several versions of this game exist and are played in different countries. This version isalso known as “Wolf and Sheep”, “Hounds and Hare” or “Devil and Tailors”. The story is told that Edward IV of England purchased two foxes and 26 hounds to form two sets of Marelles to play and it is believed that the game was called Fox
and Hounds.

This game consists of a 8x8 board on which only the dark squares are used. Two players can play the game at a time. One player represents the fox and the opposite player controls the hounds. The objective of the fox is to evade the hounds and arrive at any of the hounds’ original squares on the opposite side of the board. The objective of the hounds is to trap the fox and not let the fox reach its destination on the other side of the board.

The rules of the game are as follows:

 a. The game is played in a 8x8 board. Players can only move into the dark squares.

 b. Four hounds are initially placed on the dark squares at one edge. The fox is placed on any dark square on the opposite edge.

c. The objective of the fox is to cross from one side of the board to the other and reach any one of the hounds' original squares; the hounds' objective is to prevent it from doing so.

d. The fox can move diagonally forward or backward one square.

e. The hounds can only move diagonally forward on the dark squares. Only one hound can move in each turn.

 f. The play alternates with the fox moving first. There is no removal of pieces.

 g. The fox is trapped when it can no longer move to a vacant square. It is possible for two hounds to trap the fox against an edge of the board or even one hound can trap the fox in a corner.

h. The game closes if the fox is trapped or it reaches any one of the initial places of the hounds on the other side of the board.

 i. With perfect play, the hounds will win the game. But let’s make it more competitive. The total number of moves allowed by the hounds is 24. If the hounds cannot trap the fox within 24 moves then the fox will win!!

c.  Minesweeper

 Minesweeper [3] is a single-­­player puzzle video game. The objective of the game is to clear a rectangular board containing hidden "mines" without detonating any of them, with help from clues about the number of neighboring mines in each field. The game originates from the 1960s, and has been written for many computing platforms in use today.

Write a VBA Sub Program to create a Minesweeper game.

Create a 5 X 5 board for the game. Remember you are the person who creates the game board for others to play on.

Here are the rules that you need to keep in mind while building the game:

 a. Out of the 25 cells, 10 cells should contain mines and others contain no mines. (Hint:

Generate 10 random non-­­repetitive numbers and place the mines in those cells).

b. If a player selects the cell that contains a mine, the player loses. If the cell contains no mine then the cell should display the number of mines surrounding the cell (any cell which has at least one corner touching the currently selected cell is said to be surrounding the current cell).

c. If there are no mines in any of the cells surrounding the cell the player selected, then the player’s selected cell plus all the surrounding cells should open up.

Any game board encourages people to play if it looks creative and attractive. Design your game using your best creative skills so people will want to play your game!.

d. Battleship

 Battleship [4] is a very common game played by young children. This game consists of two 10 X 10 boards, one each for a player and their opponent. Each player initially places 5 ships. The 5 ships are of different sizes. An aircraft carrier sized 5, battleship sized 4, a submarine and destroyer both sized 2, and a patrol boat sized 2. Size specifies the number of squares across that the ship covers.

Each player places their 5 ships on the board. Only the player knows the position of their ships. The objective of the game is to find the location of all the ships of the opponent. Each location is specified by a combination of the row and the column.

The rules of the game are as follows:

 a. Each player will get a chance to guess at a square on the opponent’s board.

b. If the guessed square does not have a ship,  the square is marked as a failed target and the opponent gets a chance to guess a square.

c. If the guessed square contains a ship, the  opponent should specify which ship got hit

and mark the square as a hit. The player who hit a target ship gets another chance to guess.

d. The players should use their board to mark the squares that the opponent player guesses so that the guessed squares do not repeat as the game proceeds.

e. The winner is the one who hits all their opponents’ ships first.

 2. Please complete the online survey on D2L under surveys final course survey
Powered by