# Battleship

## Summary

This activity aims to engage students in a low-stakes activity to build confidence and review basic topics including indexing matrices and vectors, extracting data from a matrix, operating on data from a matrix, and using a matrix to store data. For this activity, we will look at a practical application of data storage. Consider the game Battleship. Two players have 5 ships each: Cruiser (length 2), Destroyer (length 3), Submarine (length 3), Battleship (Length 4), and Aircraft Carrier (length 5). Players secretly arrange their ships on a 10 by 10 grid. Players alternate bombing the opponent, by calling out a space. A player wins when they sink all of their opponent's ships. We will use the context of this game to introduce the concepts of data storage and extraction using a matrix.

## Learning Goals

The main learning objectives in this activity include (1) indexing matrices and vectors, (2) extracting data from a matrix, (3) operating on data from a matrix, and (4) using a matrix to store data. MATLAB commands are used, but the actual use of MATLAB is not necessary for this activity. This is a smaller activity in a larger set of tasks and activities focused on tactile learning for introductory programming courses.

## Context for Use

This classroom activity should be done in an introductory programming course and is best suited for smaller classes (less than 30 students). This can be done early in the semester, as it requires very few prerequisite programming skills. Students need to be familiar with basic MATLAB commands that extract data from a matrix. Although this activity was designed to be done at the beginning of the semester, the instructor may include more advanced examples if they wish to implement this later in the semester.

## Description and Teaching Materials

For this activity, we will look at a practical application of data storage. Consider the game Battleship. Two players have 5 ships each: Cruiser (length 2), Destroyer (length 3), Submarine (length 3), Battleship (Length 4), and Aircraft Carrier (length 5). Players secretly arrange their ships on a 10 by 10 grid. Players alternate bombing the opponent, by calling out a space. A player wins when they sink all of their opponent's ships. We will use the context of this game to introduce the concepts of data storage and extraction using a matrix.

- Suppose that you wanted to design a Battleship app in MATLAB. What information would you need to keep track of?
- How would you store this information?
- Matrices are a great way to store this information. Think with a partner about how you would store the following.
- Where are your ships?
- Where are your opponent's ships?
- Where have you guessed?
- Was that guess a hit or a miss?
- Where has your opponent guessed?
- Was that guess a hit or a miss?

- The figures below are pictures from a game of battleship. Store the information using matrices.
- Arrange the ships on your group's battleship board. Write down the code to store this information in MATLAB.

Battleship Handout (Acrobat (PDF) 2.2MB Sep13 23)

## Teaching Notes and Tips

This is a straightforward activity that should not require too much additional planning. As with many tasks and activities, it is important to set clear expectations before you begin. For example, make sure that you encourage collaboration and willingness to participate so that students do not feel uncomfortable. These expectations should be set on the first day of class, but it helps to reiterate them before an activity such as this. This is a rather brief activity, so be sure to plan something additional for this day of class. It is recommended that you begin class with this activity and then transition into some indexing problems using MATLAB. Once students feel comfortable with this activity, you could ask students to change seats, then randomly select a few students and determine the indexing that matches the selected students.

## Assessment

Since this is a short in-class activity, no summative assessment is necessary. However, it is easy to do a formative assessment of student understanding of indexing, extracting, and operating on data based on their participation in this activity. It is also recommended that you survey students to capture their perceptions of such activities. Note that this can be done directly following this task or after a series of tactile activities.

## References and Resources

[1] Barnes, J., & Libertini, J. M. (2018).Tactile Learning Activities in Mathematics: A Recipe Book for the Undergraduate Classroom (Vol. 54). American Mathematical Soc.