Teaching and learning with Battleship

I have been working on the Battleship project diligently.  Without two requests for help to the msdn vb.net forum and a suggested approach from Alfred Thompson I would have been dead in the water.  It is interesting to take on a program like this.  I have been teaching Small Basic for the last few years and the programs have been fairly sedate.  Usually the kids build Pong or Tic-Tac-Toe which are fairly simple.  The VB I have been teaching has been almost strictly out of the book so it was a very cook book approach and I also did some simple graphics exercises that force the kids to think procedurally but do not require a lot of fancy coding.  This Battleship program has required me to really challenge my VB coding and program design skills.  Since my formal VB training is absolutely nil I have had to rely on a couple of text books and lots of trial and error. One of the draw backs with programming in SB is there is no need to understand the passing of parameters, it does not do it.  VB on the other hand is big on parameter passing.

 My game is a two player game, not against the computer.  I did not want to deal with working out a computer play procedure that was logical and not just purely random.  One way to program a two player game is to duplicate a lot of the procedures, one for player 1 and another for player 2.  After all there are going to be two ship arrays, two game boards, two hit arrays and so on.  This simply rubbed me the wrong way.  I am one of those guys that if I see two procedures in a program that look alike, I have to figure some way to get rid of one.  He with the shortest program wins.  Thus parameter passing.  Not something I am intimately familiar with.  I should have started a project like this years ago just for the knowledge being gained.  Learning something one day and teaching it the next is not a good strategy.  But is does keep me off the streets at night. 

When I originally started this project I thought Battleship would be a fairly easy game to work up the logic for and to program.  Surprise!  There are all sorts of little details that need to be considered; things like the ships are placed either horizontally or vertically and pieces of the ship are in adjacent cells.  This is not trivial in the code; in fact I am presently ignoring this little detail because I think it is going to be a pain to code.  I have reached the point where I can place ships and shoot ships.  No player turns, score tracking or winning yet.  I am having way too much fun with this project.  I just hope I do not lose the kids; they are not quite as geeky.

4 Responses to “Teaching and learning with Battleship”

  1. Alfred Thompson Says:

    I’ve never written Battleship. THought about it several times but never got down to trying it. I’m thinking of giving it a go though. I want to work on the playing against the computer piece at some point. I think it might make a fun game for Windows Phone 7. We’ll see how I do for Windows first though.

  2. Tweets that mention Teaching and learning with Battleship « Garth's CS Education Blog -- Topsy.com Says:

    […] This post was mentioned on Twitter by Alfred Thompson, Microsoft_TeachTec. Microsoft_TeachTec said: RT @alfredtwo: Teaching and learning with Battleship http://bit.ly/dHKmHh by Cool project […]

  3. Beck McLaughlin Says:

    “Learning something one day and teaching it the next is not a good strategy. ” I understand their are drawbacks to this strategy – professional and personal. And the most fun I had teaching was when I was learning HyperCard, computer animation, sound and image editing one step ahead of and at times side by side the students.

    It was an exciting and fun time for us all.

  4. Rob Miles Says:

    Now, there’s a coincidence. We did Battleships as a programming exercise this year. I even made some video tutorials. You can find them here:

    http://cid-a4ce6a659fd80c02.office.live.com/browse.aspx/University%20Videos

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: