Requirements for Battlecell

Even if you never played Battleship as a kid, you are probably familiar with the game. Either your siblings played it, or your friends, or perhaps your own children play it now. You can also find several versions of the game on the Internet and in many department stores.

If you are familiar with the game, you might think that defining a list of requirements for the game to be a pretty easy task, but this is not necessarily the case as this program will be considerably more complex than anything you've written so far. The biggest problem is that Battlecell is the first project in this book that actually requires a bit of intelligence on the part of the computer (that is, your program) in order to properly mimic the original. Some intelligence is required by the program when selecting a target on the user's grid. Knowing, if a ship has been previously hit, what direction a ship has been placed, and how many hits are required to sink a ship all require some thought. You and I might take these things for granted when playing the game, but a computer must have instructions from the program as to the most likely location of an opponent's ship. As it turns out, adding even rudimentary intelligence to a program isn't an easy task.

Programming intelligence into a game does not require any new or immensely complicated VBA structures that I have not yet discussed; however, what it does require is a clever algorithm (plan).

Because it would likely double the length of the program, and the major goal of the Battlecell program is to give you experience with Excel's most common VBA objects, I've decided to skip adding the intelligence to this program. Instead, I will walk you through the use of the Workbook, Worksheet, and Range objects to program the layout and basic operation of the game. I will even add a little multimedia in the form of sound to make it more exciting. I highly encourage you to come back to this program at some point and add an intelligent component to the program that helps the computer play more competitively.

Biorhythm Awareness

Biorhythm Awareness

Who else wants to take advantage of biorhythm awareness to avoid premature death, escape life threatening diseases, eliminate most of your life altering mistakes and banish catastrophic events from your life.

Get My Free Ebook


Post a comment