Lesson video

In progress...

Loading...

Hello, my name is Mrs. Holborow and welcome to Computing.

I'm so pleased you've decided to join me for the lesson today.

In today's lesson, we are going to be using our knowledge of dictionaries to create a battle boats game.

Welcome to today's lesson from the unit Dictionaries and Data Files.

This lesson is called Programming Project - Dictionaries I.

And by the end of today's lesson, you'll be able to develop a set of success criteria from a project brief and use the criteria to start developing a solution.

Shall we make a start? We will be exploring these keywords throughout today's lesson.

Let's take a look at them now.

Success criteria, success criteria: specific, measurable, and realistic benchmarks used to determine if a project, task, or outcome has been accomplished successfully.

Code log, code log: a document that you use when developing a programme to keep track of your progress throughout the project.

Look out for these keywords throughout today's lesson.

Today's lesson is broken down into two parts.

We'll start by creating success criteria for a project.

We'll then move on to log development of code during development.

Let's make a start by creating success criteria for a project.

Battle boats is a turn-based strategy game where players eliminate their opponent's fleet of boats by firing at a location on a grid to try and sink them.

The first player to sink all of their opponent's battle boats is declared the winner.

Each player has two eight-by-eight grids.

One grid, which is shown in Figure 1 is used for their own battle boats and the other Figure 2 is used to record any hits or misses from firing at their opponent's battle boats.

At the beginning of the game, players decide where they wish to place their fleet of five battle boats.

So you can see in Figure 1, there are five B's which have been put on the grid by the player.

On Figure 2, you can see the letters M or H, which indicate whether the player has hit or missed the opponent's battle boat.

Time to check your understanding.

What type of data structure would be most appropriate to create the grid for the battle boats game? Is it A, a list; B, a 2D list; or C, a dictionary.

Pause the video whilst you have a think.

That's right, a dictionary.

A dictionary would be most appropriate as the key value pairs could be used to hold the boat locations or whether the guess was a hit or a miss.

During gameplay, players take in turns to fire at a location on their opponent's grid.

They do this by stating the coordinates of their target.

So for example, A1, F6, et cetera.

If a player hits their opponent's boat, this is recorded as a hit with the letter H.

If they miss, then this is recorded as a miss with the letter M.

So you can see here H2 has been recorded as a hit and A3 has been recorded as a miss.

The game ends when a player's fleet of boats have been sunk.

The winner is the player with boats remaining at the end of the game.

You have been asked to design a battle boats game where the user plays against the computer to try to sink its fleet of boats.

Your tasks to develop the battle boats game are the following: One, develop a menu that will allow the user to select A, play a new game; B, read the instructions; or C, quit the game.

Two, develop the part of the programme that starts a new game.

The programme should: A, present the user with a blank fleet grid, which is shown in Figure 3; B, prompt the player to enter coordinates for each boat; C, check if a boat has already been placed in the specific location; D, display each boat on the fleet grid after each entry; and E, only allow a player to enter five boat locations.

For part three, develop the part of the programme that randomly generates five unique locations for the computer's fleet.

These locations should not be revealed to the player.

Note, the computer's fleet will not be displayed to the user at any point in the game.

But for testing purposes, it will be necessary to display the locations, but these should not appear in the finished game.

For part four, develop the part of the programme that displays a blank target tracker for the player.

This is shown in Figure 4.

For part five, develop the part of the programme that allows a player to take their turn.

The programme should: A, prompt for the target coordinates.

Note, the programme should not allow the player to enter the same coordinates twice.

B, check if the target is a hit or miss; C, display H on the target tracker if the target is a hit; and D, display an M on the target tracker if the target is a miss.

For part six, develop the part of the programme that allows the computer to take their turn.

The programme should: A, randomly generate target coordinates.

Note, the programme should not be allowed to generate the same target coordinates twice.

B, display the coordinates to the player; C, check if the target is a hit or a miss; D, replace the B with a H on the player's fleet grid if the target is a hit; E, if the target is a miss, then this should be recorded by the programme, but there is no need to display a miss on the player's fleet grid.

For part seven, develop the part of the programme that continues the game until there is a winner.

A game has been won when a player has sunk all of their opponents battle boats.

The winner of the game should be displayed to the player.

Time to check your understanding.

Which grid is this for the game? Is it A, the target grid; or B, the fleet grid? Pause the video whilst you have a think.

Well done, it's the target grid.

Remember, the target grid records whether a hit or miss has been made.

The fleet grid is used to record the locations of the player's boats.

This is the target grid because it records if the guest was a hit or a miss.

Before you begin a large project like the battle boats game, it can be helpful to write the success criteria.

Success criteria are the benchmarks that your project will need to do in order for it to be a success.

The success criteria list can then be used to help you develop the programme.

It can also be used to help you complete the final testing of your programme.

Here is the first task for the project.

In order to use this to create a list of success criteria, it can be useful to highlight any key points.

So here, we've highlighted that we need a menu.

It needs to have a new game option, instructions, and a quit the game option.

So the success criteria for task 1 is there is a menu system and that the menu options are new game, instructions, and quit.

Okay, we are moving on to our first task of today's lesson.

For each main task for the battle boats game, create a list of success criteria, similar to the ones we've just seen for task 1.

Note, an outline of the project brief for the battle boats game is included as an additional material for this lesson.

So if you want to have that open, it might be a good idea.

Pause the video here whilst you develop your success criteria.

Okay, we are now moving on to the second part of today's lesson where we're going to log development of code during development.

Open the noughts and crosses programme at oak.

link/xo-game.

What are the similarities between this and the battle boats game? Pause the video here whilst you open the programme and go and have a look.

Lucas says, "There are two players." That's the same for the battle boats game too.

Well done, Lucas.

Laura says, "It uses a fixed grid." Yes, although the grid is a slightly different size, it's the same principle as the battle boats game.

Well done, Laura.

And Izzy says, "Items on the grid are accessed and modified." That's an excellent point, Izzy.

We modify the noughts and crosses grid by placing the nought or the cross, and we want to do a similar thing in the battle boats game.

Time to check your understanding.

Laura has started writing some code to set up a dictionary with eight-by-eight grid for the battle boats game.

What programming structure could be used to assign an initial value to each record in the dictionary? Pause the video here whilst you have a think.

Did you spot it? A for loop could be used to iterate through each row and column to add an initial value.

A code log is a document that you can use when developing a programme to keep track of: your progress throughout your project, decisions that you have made and why, problems that you have come across and how you solve them, and test results that show that your programme works correctly.

In your code log, take screenshots of your work as you move through the success criteria and write a few sentences about what you did and any issues that you've had along the way.

It's a bit like a diary of code development.

Fill in the gaps to complete the sentence.

A code log is a document that you can use when developing a programme to keep track of your, throughout the project and any, that you have made along the way and why.

Pause the video whilst you fill in the gaps.

How did you get on? Let's have a look at the sample answer together.

A code log is a document that you can use when developing a programme to keep track of your progress throughout the project and any decisions that you have made along the way and why.

Here's a blank template of a code log.

So you can see we have space to add screenshots of your code at the top.

We then have some sample questions.

What worked well for you today? What was challenging for you today? And what are your next steps? Here's Izzy's completed code log.

So Izzy has taken a screenshot of the subroutine that she's created for the menu.

What worked well for you today? Izzy says, "I found it fairly easy to create the subroutine for the menu." What are your next steps? "My next step is to create the subroutine for the instructions." Okay, we're moving on to our second task of today's lesson and you've done a fantastic job, so well done.

I'd like you to use your success criteria from Task A to start creating the battle boats game.

As you work through the project, use a code log to document your progress.

So remember, you're gonna need to take some screenshots as you go and put these inside your code log.

Note: A code log template is included as additional material for this lesson.

Pause the video here whilst you go and have a go at creating your solution.

How did you get on? Did you manage to start coding your battle boats solution? Well done, we've come to the end of today's lesson Programming Project - Dictionaries I.

Let's summarise what we've learned together during today's lesson.

Before you begin a large project, it can be helpful to write the success criteria.

Success criteria are specific, measurable, and realistic benchmarks used to determine if a project, task or outcome has been accomplished successfully.

A code log is a document that you can use when developing a programme to keep track of your progress.

It can record any problems that you've come across and how you solve them.

I hope you've enjoyed today's lesson and I hope you join me again soon, bye.